Esempio n. 1
0
 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"));
     }
 }
Esempio n. 2
0
        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));
        }
Esempio n. 3
0
 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)));
     }
 }
Esempio n. 4
0
        public async Task <IActionResult> Create(NVCreateRequest request)
        {
            var result = await _nhanVienService.Create(request);

            return(Ok(result));
        }