Exemplo n.º 1
0
        public async Task <ActionResult> postSuaNV(NhanVien nhanv)
        {
            var nhanvien = await _context.NhanVien.FindAsync(nhanv.Idnv);

            if (nhanvien == null)
            {
                return(NotFound());
            }
            NhanVien nvToUpdate = _context.NhanVien.Single(nv => nv.Idnv == nhanv.Idnv);

            nvToUpdate.Name     = nhanv.Name;
            nvToUpdate.Brithday = nhanv.Brithday;
            nvToUpdate.Address  = nhanv.Address;
            nvToUpdate.Phone    = nhanv.Phone;
            nvToUpdate.Email    = nhanv.Email;
            nvToUpdate.CaLam    = nhanv.CaLam;
            nvToUpdate.BacLuong = nhanv.BacLuong;
            nvToUpdate.Cmnd     = nhanv.Cmnd;
            nvToUpdate.MaThue   = nhanv.MaThue;
            nvToUpdate.Thuong   = nhanv.Thuong;

            nvToUpdate.PhuCap = nhanv.PhuCap;
            try { _context.SaveChanges(); }catch (Exception ex) { Console.WriteLine(ex.Message); }

            return(CreatedAtAction(nameof(getNhanVienById), new { id = nvToUpdate.Idnv }, nvToUpdate));
        }
Exemplo n.º 2
0
        public async Task <ActionResult> PostThemViTri(ViTri vtMoi)
        {
            if (vtMoi == null)
            {
                return(BadRequest("Nhân Viên Đã Thuộc Phòng Ban Rồi"));
            }
            await _context.ViTri.AddAsync(vtMoi);

            _context.SaveChanges();
            //   return Ok("Added");
            return(CreatedAtAction(nameof(GetViTriBYId), new { id = vtMoi.IdNv }, vtMoi));
        }
Exemplo n.º 3
0
        public async Task <ActionResult> postSuaTTPhongBan(PhongBan phongban)
        {
            var phong = await _context.PhongBan.FindAsync(phongban.Idpb);

            if (phong == null)
            {
                return(NotFound());
            }
            PhongBan pbToUpdate = _context.PhongBan.Single(pb => pb.Idpb == phongban.Idpb);

            pbToUpdate.Name = phongban.Name;

            _context.SaveChanges();
            return(CreatedAtAction(nameof(GetPhongBanById), new { id = phongban.Idpb }, phongban));
        }