public IActionResult Create([Bind("MaVaiTro,HoTen,GioiTinh,NgaySinh,DiaChi")] SaveNhanVienDTO nhanVien) { if (HttpContext.Session.GetString("Username") != null && HttpContext.Session.GetString("Role") == "1") { _service.Create(nhanVien); return(RedirectToAction(nameof(Index))); } else { return(RedirectToAction("Index", "Account")); } }
public ActionResult <ResponseResult <NhanVien> > Create(NhanVien nhanvien) { try { _nvService.Create(nhanvien); } catch (Exception e) { var res = new ResponseResult <NhanVien>(); res.Code = "500"; res.Message = "Create Failed : " + e.Message; return(res); } return(CreatedAtRoute("GetNhanVien", new { id = nhanvien.id.ToString() }, nhanvien)); }
public async Task <BaseResponse> Create(NhanVienDTO NhanVienDto) { try { var result = _NhanVienService.Create(NhanVienDto); if (result) { return(await Task.FromResult(new BaseResponse(result))); } return(await Task.FromResult(new BaseResponse(Message.CreateNotSuccess))); } catch (Exception e) { return(await Task.FromResult(new BaseResponse(Message.CreateNotSuccess))); } }
public async Task <IActionResult> Create(NVCreateRequest request) { var result = await _nhanVienService.Create(request); return(Ok(result)); }