public ActionResult Create(Statistic statistic) { if (ModelState.IsValid) { statisticRepository.InsertOrUpdate(statistic); statisticRepository.Save(); return RedirectToAction("Index"); } else { return View(); } }
private void CreateNewStatistic(Statistic statistic) { statistic = new Statistic(); statistic.UserId = WebSecurity.CurrentUserId; statistic.CountLikes = 0; statistic.Time = date; }
private void SaveRepository(Statistic statistic, Like like, Track track) { trackRepository.InsertOrUpdate(track); trackRepository.Save(); likeRepository.Save(); _statisticRepository.InsertOrUpdate(statistic); _statisticRepository.Save(); }
public void InsertOrUpdate(Statistic statistic) { if (statistic.StatisticId == default(int)) { // New entity context.Statistics.Add(statistic); } else { // Existing entity context.Entry(statistic).State = EntityState.Modified; } }