public ActionResult NewTopic(TopicVM vm) { if (repo.GetById(vm.ClassId) == null) { return(HttpNotFound()); } if (ModelState.IsValid) { var top = new ClassTopic { Topic = vm.Topic, ClassId = vm.ClassId, Order = vm.Order }; _db.ClassTopic.Add(top); _db.SaveChanges(); return(PartialView("PartialAllClassTopics", GetAllTopics(top.ClassId))); } return(PartialView("PartialClassTopic", vm)); }
public static ClassTopic ToEntity(ViewClassTopic model) { ClassTopic item = new ClassTopic(); item.Id = model.Id; item.ClassID = model.ClassID; item.TopicID = model.TopicID; item.IsDeleted = model.IsDeleted; item.CreateTime = model.CreateTime; return(item); }
public static ViewClassTopic ToViewModel(ClassTopic model) { if (model == null) { return(null); } ViewClassTopic item = new ViewClassTopic(); item.Id = model.Id; item.ClassID = model.ClassID; item.TopicID = model.TopicID; item.IsDeleted = model.IsDeleted; item.CreateTime = model.CreateTime; return(item); }