我在我的应用程序中使用 ajax 工具包评级控制。应用程序是在 asp.net 网络表单中进行的。现在我需要更改 Metro 中的应用程序设计。我正在使用 Metro UI CSS,但在评级控制方面遇到了问题。
使用 ajax,我在后面的代码中使用了这段代码来保存数据库中的速率:
protected void Rating_Changed(object sender, RatingEventArgs e)
{
int rowIndex = ((sender as Rating).NamingContainer as GridViewRow).RowIndex;
int accommodationId = Convert.ToInt32(gvAccommodations.DataKeys[rowIndex].Value);
var context = new RezervacijaSmjestajaDbContext();
var accommodation =
(
from a in context.Accommodations.ToList()
where a.Id == accommodationId
select a
)
.Single();
accommodation.BrojOcjena++;
double NovaOcjena = Convert.ToDouble(e.Value);
accommodation.ZbrojOcjena = accommodation.ZbrojOcjena + NovaOcjena;
accommodation.Rating = accommodation.ZbrojOcjena / accommodation.BrojOcjena;
context.SaveChanges();
}
如果我使用 Metro UI CSS 评级控件,如何在数据库中保存费率?