public ActionResult Create([Bind(Include = "ModuleId,ModuleCode,ModuleName,Status,CreateDate,CreateBy,ModifiedDate,ModifiedBy")] Module module) { if (ModelState.IsValid) { db.Modules.Add(module); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(module)); }
public void Create(Module module) { if (!UpdateDatabase) { var first = GetAll().OrderByDescending(e => e.ModuleId).FirstOrDefault(); var id = (first != null) ? first.ModuleId : 0; module.ModuleId = id + 1; GetAll().Insert(0, module); } else { var entity = new Module(); entity.ModuleId = module.ModuleId; entity.ModuleCode = module.ModuleCode; entity.ModuleName = module.ModuleName; entity.Status = module.Status; entity.CreateDate = DateTime.Today.Date; entity.CreateBy = "Admin"; db.Modules.Add(entity); db.SaveChanges(); module.ModuleId = entity.ModuleId; } }