public void UpdateClass(ViewClassesModel viewclass) { var upclass = _Iclasses.GetClass(viewclass.Id); CopyToClass(viewclass, upclass); _Iclasses.UpdateClass(upclass); }
private void CopyToClass(ViewClassesModel vcm, Classes cls) { cls.ClassName = vcm.ClassName; cls.CRN = vcm.CRN; cls.EndDate = vcm.EndDate; cls.StartDate = vcm.StartDate; cls.Id = vcm.Id; cls.UserId = vcm.UserId; }
public ActionResult Create(ViewClassesModel ClassViewModel) { if (ModelState.IsValid) { _Iservice.SaveClass(ClassViewModel); return(RedirectToAction("List", new { UserId = ClassViewModel.UserId })); } return(View()); }
private void Save(ViewClassesModel ClassViewModel) { var dbContext = new AppDb(); var Class = MapToClass(ClassViewModel); dbContext.Classes.Add(Class); dbContext.SaveChanges(); }
private Classes MapToClass(ViewClassesModel ViewModel) { return(new Classes { Id = ViewModel.Id, ClassName = ViewModel.ClassName, StartDate = ViewModel.StartDate, EndDate = ViewModel.EndDate, UserId = ViewModel.UserId }); }
public ActionResult ViewClasses() { ViewBag.savedChanges = false; ViewBag.noEdit = false; ViewClassesModel model = new ViewClassesModel(); //Handle cases for success banner in the Admin/ViewClasses view if (TempData["AddClass"] != null || TempData["EditClass"] != null) { //Case 1: The admin adds a new class and it is successful if (TempData["AddClass"] != null) { ViewBag.newClass = true; ViewBag.className = TempData["AddClass"]; } //Case 2: The admin edits a class and it is successful else if (TempData["EditClass"] != null) { ViewBag.newClass = false; ViewBag.className = TempData["EditClass"]; } ViewBag.savedChanges = true; } //Case 3: The admin presses the submit button from the EditClass page but changes nothing else if (TempData["NoEdit"] != null) { ViewBag.noEdit = true; ViewBag.className = TempData["NoEdit"]; } using (var db = new CopiosisEntities()) { model.ItemClassTemplates = db.itemClasses.Select(t => new ViewClassModel { classID = t.classID, className = t.name, numUsing = db.products.Where(p => p.itemClass == t.classID).Count() }).OrderByDescending(t => t.className).ToList(); } return(View(model)); }
public double CheckClassDelta(ViewClassesModel viewclass) { double delta = (viewclass.EndDate - viewclass.StartDate).TotalDays; return(delta); }
public void SaveClass(ViewClassesModel cls) { var Class = MapToClass(cls); _Iclasses.SaveClass(Class); }