示例#1
0
        public async Task <IHttpActionResult> Put(string id, NvKiemKeVm.Dto instance)
        {
            //Lấy danh sách các mã không thuộc kệ để update lại mã kệ cho các mã đó
            List <NvKiemKeVm.DtoDetails> hangKhongThuocKe = new List <NvKiemKeVm.DtoDetails>();

            foreach (NvKiemKeVm.DtoDetails data in instance.DataDetails)
            {
                if (data.KeKiemKe == instance.KeKiemKe)
                {
                }
                else
                {
                    hangKhongThuocKe.Add(data);
                }
            }

            //Update mã kệ trong danh mục hàng hóa
            foreach (NvKiemKeVm.DtoDetails value in hangKhongThuocKe)
            {
                MdMerchandise maHangHoa = _service.Repository.DbSet.FirstOrDefault(x => x.MaVatTu == value.MaVatTu);
                if (maHangHoa != null)
                {
                    maHangHoa.MaKeHang = instance.KeKiemKe;
                    _service.Update(maHangHoa);
                }
            }
            await _service.UnitOfWork.SaveAsync();

            //end cập nhật mã kệ

            TransferObj <NvKiemKe> result = new TransferObj <NvKiemKe>();
            NvKiemKe check = _serviceKK.FindById(instance.Id);

            if (id != instance.Id || check.TrangThai == (int)ApprovalState.IsComplete)
            {
                return(NotFound());
            }
            try
            {
                NvKiemKe item = _serviceKK.UpdatePhieu(instance);
                await _serviceKK.UnitOfWork.SaveAsync();

                result.Status = true;
                result.Data   = item;
                return(Ok(result));
            }
            catch (Exception e)
            {
                return(InternalServerError());
            }
        }
示例#2
0
        public async Task <IHttpActionResult> PostListHangHoa(List <MdMerchandise> instance)
        {
            var result = new TransferObj <MdMerchandise>();

            foreach (var value in instance)
            {
                try
                {
                    var item = _serviceMerchandise.Update(value);
                }
                catch (Exception e)
                {
                    result.Status  = false;
                    result.Message = e.Message;
                    return(Ok(result));
                }
            }
            _serviceMerchandise.UnitOfWork.Save();
            result.Status = true;
            return(Ok(result));
        }