Пример #1
0
        public async Task Update(int id, MaterialDeliveryNoteViewModel viewModel)
        {
            var model = new Data.MaterialDeliveryNoteModel(null, viewModel.DateSJ, viewModel.BonCode, viewModel.DateFrom, viewModel.DateTo, viewModel.DONumber.Id.GetValueOrDefault(), viewModel.DONumber.DOSalesNo, viewModel.FONumber, viewModel.buyer.Id.GetValueOrDefault(), viewModel.buyer.Code,
                                                           viewModel.buyer.Name, viewModel.Remark, viewModel.salesContract.SalesContractId.GetValueOrDefault(), viewModel.salesContract.SalesContractNo, viewModel.unit.Id.GetValueOrDefault(), viewModel.unit.Code, viewModel.unit.Name,
                                                           viewModel.storage.Id.GetValueOrDefault(), viewModel.storage.Code, viewModel.storage.Name,
                                                           viewModel.Items.Select(s => new ItemsModel(s.IdSOP, s.NoSOP, s.MaterialName, s.InputLot, s.WeightBruto, s.WeightDOS, s.WeightCone, s.WeightBale, s.GetTotal)).ToList());

            await _MaterialDeliveryNoteRepository.UpdateAsync(id, model);
        }
Пример #2
0
        private MaterialDeliveryNoteViewModel MapToViewModel(Data.MaterialDeliveryNoteModel model)
        {
            var vm = new MaterialDeliveryNoteViewModel()
            {
                Active   = model.Active,
                Id       = model.Id,
                Code     = model.Code,
                DateSJ   = (DateTimeOffset)model.DateSJ,
                BonCode  = model.BonCode,
                DateFrom = (DateTimeOffset)model.DateFrom,
                DateTo   = (DateTimeOffset)model.DateTo,
                DONumber = new DeliveryOrderMaterialDeliveryNoteWeaving()
                {
                    Id        = model.DoNumberId,
                    DOSalesNo = model.DONumber
                },
                FONumber = model.FONumber,
                buyer    = new BuyerMaterialDeliveryNoteWeaving()
                {
                    Id   = model.ReceiverId,
                    Code = model.ReceiverCode,
                    Name = model.ReceiverName
                },
                Remark        = model.Remark,
                salesContract = new SalesContract()
                {
                    SalesContractNo = model.SCNumber,
                    SalesContractId = model.SCNumberId
                },
                unit = new UnitMaterialDeliveryNoteWeaving()
                {
                    Id   = model.SenderId,
                    Code = model.SenderCode,
                    Name = model.SenderName
                },
                storage = new StorageMaterialDeliveryNoteWeaving()
                {
                    Id   = model.StorageId,
                    Code = model.StorageCode,
                    Name = model.StorageName
                },
                Items = model.Items.Select(d => new ItemsViewModel()
                {
                    IdSOP        = d.IdSOP,
                    NoSOP        = d.NoSOP,
                    MaterialName = d.MaterialName,
                    InputLot     = d.InputLot,
                    WeightBruto  = d.WeightBruto,
                    WeightDOS    = d.WeightDOS,
                    WeightCone   = d.WeightCone,
                    WeightBale   = d.WeightBale,
                    GetTotal     = d.GetTotal
                }).ToList()
            };

            return(vm);
        }
Пример #3
0
        public async Task <MaterialDeliveryNoteViewModel> ReadById(int id)
        {
            var model = await _MaterialDeliveryNoteRepository.ReadByIdAsync(id);

            if (model == null)
            {
                return(null);
            }
            MaterialDeliveryNoteViewModel vm = MapToViewModel(model);

            return(vm);
        }
Пример #4
0
        public async Task Create(MaterialDeliveryNoteViewModel viewModel)
        {
            var model = new Data.MaterialDeliveryNoteModel(null, viewModel.DateSJ, viewModel.BonCode, viewModel.DateFrom, viewModel.DateTo, viewModel.DONumber.Id.GetValueOrDefault(), viewModel.DONumber.DOSalesNo, viewModel.FONumber, viewModel.buyer.Id.GetValueOrDefault(), viewModel.buyer.Code,
                                                           viewModel.buyer.Name, viewModel.Remark, viewModel.salesContract.SalesContractId.GetValueOrDefault(), viewModel.salesContract.SalesContractNo, viewModel.unit.Id.GetValueOrDefault(), viewModel.unit.Code, viewModel.unit.Name,
                                                           viewModel.storage.Id.GetValueOrDefault(), viewModel.storage.Code, viewModel.storage.Name,
                                                           viewModel.Items.Select(s => new ItemsModel(s.IdSOP, s.NoSOP, s.MaterialName, s.InputLot, s.WeightBruto, s.WeightDOS, s.WeightCone, s.WeightBale, s.GetTotal)).ToList());

            foreach (var itm in viewModel.Items)
            {
                var modelItem = new ItemsModel(itm.IdSOP, itm.NoSOP, itm.MaterialName, itm.InputLot, itm.WeightBruto, itm.WeightDOS, itm.WeightCone, itm.WeightBale, itm.GetTotal);

                await _ItemsRepository.InsertAsync(modelItem);
            }

            await _MaterialDeliveryNoteRepository.InsertAsync(model);
        }