public JsonResult SaveDataDatabase(List <ResultViewModel> lst) { try { if (lst.Count() > 0) { var listCal = resultDao.ListCalendarID().Where(x => x.CalendarID == lst[0].CalendarID).ToList(); if (listCal.Count() > 0) { return(Json(new { status = -1, title = "Lỗi", type = "error", msg = "Trận đấu đã trùng" })); } foreach (var item in lst) { Result Stu = new Result(); Stu.CalendarID = lst[0].CalendarID; Stu.MemberID = item.MemberID; Stu.Goal = item.Goal; Stu.Lost = item.Lost; Stu.Point = item.Point; Stu.Yellowcard = item.Yellowcard; Stu.Redcard = item.Redcard; db.Results.Add(Stu); db.SaveChanges(); } } else { return(Json(new { status = -2, title = "Lỗi", type = "error", msg = "Bạn chưa nhập dữ liệu" })); } } catch (Exception ex) { throw ex; } return(Json(new { status = 1, msg = "Thêm kết qua thành công" })); }
public void AddNewCalender(Calendar entity) { db.Calendars.Add(entity); db.SaveChanges(); }