// GET: YeuCauDatLuongCoBanController/Create public async Task <ActionResult> Create(string employeeChuTheId) { var model = new YeuCauDatLuongCoBanVM(); model.MaNhanVienDuocDatLuong = employeeChuTheId; return(View(model)); }
public async Task <ActionResult> Create(YeuCauDatLuongCoBanVM model) { try { if (!ModelState.IsValid) { return(View(model)); } if (model.MucLuongCoBan <= 0) { ModelState.AddModelError("", "Mức lương phải lớn hơn 0"); return(View(model)); } var employee = await _userManager.GetUserAsync(User); var yeuCauDatLuongCoBan = _mapper.Map <YeuCauDatLuongCoBan>(model); yeuCauDatLuongCoBan.MaNhanVienGuiYeuCau = (await _userManager.GetUserAsync(User)).Id; yeuCauDatLuongCoBan.ThoiGianGuiYeuCau = DateTime.Now; yeuCauDatLuongCoBan.MaYeuCau = Guid.NewGuid().ToString(); yeuCauDatLuongCoBan.TinhTrangPheDuyet = YeuCauDatLuongCoBanStatusString[YeuCauDatLuongCoBanStatus.DangCho]; var isSuccess = await _YeuCauDatLuongCoBanRepo.Create(yeuCauDatLuongCoBan); if (!isSuccess) { ModelState.AddModelError("", "Something went wrong with submitting your record"); return(View(model)); } return(RedirectToAction(nameof(MyRequest))); } catch (Exception ex) { ModelState.AddModelError("", "Something went wrong"); return(View(model)); } }