public ActionResult SendReport(ReportMonth model, string submit) { if (submit == "Gửi") { if (model != null) { model.Name = model.Name.ToString().Trim() ?? ""; model.ClassName = model.ClassName; model.Date = model.Date; model.Files = model.Files; model.CreatedDate = model.CreatedDate.GetValueOrDefault(System.DateTime.Now);; db.ReportMonth.Add(model); db.SaveChanges(); } SetAlert("Đã gửi báo cáo tháng thành công! :D", "success"); return(RedirectToAction("Index")); } else if (submit == "Cập Nhật") { if (model != null) { var list = db.ReportMonth.SingleOrDefault(x => x.ID == model.ID); list.Name = model.Name; list.ClassName = model.ClassName.ToString(); db.SaveChanges(); model = null; } SetAlert("Cập nhật mẫu báo cáo thành công! :D", "success"); return(RedirectToAction("Index")); } else { List <ReportMonth> list = GetDataReport().OrderBy(s => s.Name).ToList(); return(View("Index", list)); } }
public void AddMonth(ReportMonth reportMonth) => _report.Add(reportMonth);