public async Task <IActionResult> Update(MN_License model) { if (!ModelState.IsValid) { return(View(model)); } var oldObj = await _MN_LicenseService.GetById(model.Id); if (oldObj == null) { ModelState.AddModelError("", "Bản ghi không tồn tại"); return(View(model)); } // var existed = await _MN_LicenseService.GetByName(model.ProjectName); if (existed != null && existed.Id != model.Id) { ModelState.AddModelError("ProjectName", "Tên đã tồn tại"); return(View(model)); } oldObj.IsExpire = model.IsExpire; oldObj.ProjectName = model.ProjectName; oldObj.ExpireDate = model.ExpireDate; var result = await _MN_LicenseService.Update(oldObj); if (result.isSuccess) { return(RedirectToAction("Index")); } else { ModelState.AddModelError("", result.Message); return(View(model)); } }
public async Task <IActionResult> Create(MN_License model, bool SaveAndCountinue = false) { if (!ModelState.IsValid) { return(View(model)); } // var existed = await _MN_LicenseService.GetByName(model.ProjectName); if (existed != null) { ModelState.AddModelError("ProjectName", "Tên này đã tồn tại"); return(View(model)); } model.Id = ObjectId.GenerateNewId().ToString(); //Thực hiện thêm mới var result = await _MN_LicenseService.Create(model); if (result.isSuccess) { if (SaveAndCountinue) { TempData["Success"] = "Thêm mới thành công"; return(RedirectToAction("Create")); } return(RedirectToAction("Index")); } else { ModelState.AddModelError("", result.Message); return(View(model)); } }
public async Task <IActionResult> Create(MN_License model) { model = new MN_License(); return(View(await Task.FromResult(model))); }
public async Task <MessageReport> Create(MN_License model) { return(await _MN_LicenseRepository.Add(model)); }