Example #1
0
 public void CreateOrEditThuHoi(ThuHoiInput thuHoiInput)
 {
     if (thuHoiInput.Id == 0)
     {
         Create(thuHoiInput);
     }
     else
     {
         Update(thuHoiInput);
     }
 }
Example #2
0
        private void Update(ThuHoiInput thuHoiInput)
        {
            var thuHoiEnity = thuHoirepository.GetAll().Where(x => !x.IsDelete).SingleOrDefault(x => x.Id == thuHoiInput.Id);

            if (thuHoiEnity == null)
            {
            }
            ObjectMapper.Map(thuHoiInput, thuHoiEnity);
            SetAuditEdit(thuHoiEnity);
            thuHoirepository.Update(thuHoiEnity);
            CurrentUnitOfWork.SaveChanges();
        }
Example #3
0
        private void Create(ThuHoiInput thuHoiInput)
        {
            var capPhatEnity = capPhatrepository.GetAll().Where(x => !x.IsDelete).SingleOrDefault(x => x.TenDonVi == thuHoiInput.TenDonViThuHoi && x.MaTaiSan == thuHoiInput.MaTaiSan);

            if (capPhatEnity != null && thuHoiInput.SoLuong > capPhatEnity.SoLuong || capPhatEnity == null)
            {
                return;
            }

            var thuHoiEnity = ObjectMapper.Map <ThuHoi>(thuHoiInput);

            SetAuditInsert(thuHoiEnity);
            thuHoirepository.Insert(thuHoiEnity);

            var taiSanEnity = taisanrepository.GetAll().Where(x => !x.IsDelete).SingleOrDefault(x => x.Id == thuHoiInput.MaTaiSan);

            taiSanEnity.SoLuong += thuHoiInput.SoLuong;

            CurrentUnitOfWork.SaveChanges();
        }
Example #4
0
 public void CreateOrEditThuHoi([FromBody] ThuHoiInput input)
 {
     thuHoiAppservice.CreateOrEditThuHoi(input);
 }