Beispiel #1
0
        private void ProcessQuotationData(IEnumerable <Quotation> quotations, DataOP op)
        {
            if (quotations == null)
            {
                return;
            }

            foreach (var quotation in quotations)
            {
                quotation.RequestHeaderId = RequestHeader.Id;
                if (DataOP.AddNew == op)
                {
                    _quotationRepository.Add(quotation);
                }
                else if (DataOP.EDIT == op)
                {
                    _quotationRepository.Update(quotation);
                }
                else if (DataOP.DEL == op)
                {
                    var removeRecord = _quotationRepository.GetById(quotation.Id);
                    if (removeRecord != null)
                    {
                        _quotationRepository.Delete(removeRecord);
                    }
                }
            }
        }
Beispiel #2
0
 private void SaveModels(Quotation quotationLocal)
 {
     _quotationRepository.Add(quotationLocal);
     _orderDetailsRepository.Add(_OrderAndOrderDetailsVM.OrderDetailsModel);
     _orderRepository.Add(_OrderAndOrderDetailsVM.OrderModel);
     try
     {
         _queries.SaveChanges();
     }
     catch (Exception ex)
     {
     }
 }
Beispiel #3
0
 public Task <object> Handle(AddNewQuotationCommand command, CancellationToken cancellationToken)
 {
     Entities.Quotation u = new Entities.Quotation(
         null,
         new Entities.Customer((uint)command.CustomerId, null, null, null, null, null, null, null, null),
         new StartDate(command.StartDate),
         null
         );
     if (!command.IsValid())
     {
         NotifyValidationErrors(command);
     }
     else
     {
         QuotationModel model = _QuotationRepository.Add(u);
         if (model != null)
         {
             return(Task.FromResult(model as object));
         }
         _bus.RaiseEvent(new DomainNotification("Quotation", "Server error", NotificationCode.Error));
     }
     return(Task.FromResult(null as object));
 }
Beispiel #4
0
 public void Create(Quotation Quotation)
 {
     _QuotationRepository.Add(Quotation);
     _UnitOfWork.Commit();
 }
Beispiel #5
0
        public IActionResult PostNewOrders([FromBody] PostManageOrdersVM _pmovm)
        {
            List <string> serviceIdList = _pmovm.idService.Split(',').ToList();

            foreach (var serviceId in serviceIdList)
            {
                OrderDetails _OrderDetailsNueva = new OrderDetails();
                var          quotationLocal     = new Quotation();
                quotationLocal.Tasks     = new List <TaskModel>();
                _OrderDetailsNueva.Order = _queries.GetOrderByOrderId(_pmovm.orderId);
                Guid id = Guid.Parse(serviceId);
                _OrderDetailsNueva.Service = _queries.GetServiceFirstOrDefault(id);
                var quotation = _queries.GetQuotationIncludeOrderTaskListMaterialWhereOrderIdEqualsOrderId(_pmovm.orderId);
                var pics      = _queries.GetQuotationIncludeOrderDetailsOrderTaskPicturesFirstOrDefaultWhereOrderIdEquals(_pmovm.orderId);

                for (int i = 0; i < quotation.Tasks.Count; i++)
                {
                    var _taskLocal = new TaskModel();

                    for (int f = 0; f < quotation.Tasks[i].ListMaterial.Count; f++)
                    {
                        if (_taskLocal.ListMaterial == null)
                        {
                            _taskLocal.ListMaterial = new List <Material>();
                        }
                        var mat = new Material();
                        mat.Description = quotation.Tasks[i].ListMaterial[f].Description;
                        mat.Name        = quotation.Tasks[i].ListMaterial[f].Name;
                        mat.Price       = 0;
                        _taskLocal.ListMaterial.Add(mat);
                    }

                    if (_taskLocal.Pictures == null)
                    {
                        _taskLocal.Pictures = new List <Picture>();
                    }

                    for (int e = 0; e < pics.Tasks[i].Pictures.Count; e++)
                    {
                        var picLocal = new Picture();
                        picLocal.PictureBytes = pics.Tasks[i].Pictures[e].PictureBytes;
                        picLocal.Tipo         = PictureTypeEnum.Quotation;
                        _taskLocal.Pictures.Add(picLocal);
                    }
                    _taskLocal.Name        = quotation.Tasks[i].Name;
                    _taskLocal.Duration    = quotation.Tasks[i].Duration;
                    _taskLocal.Description = quotation.Tasks[i].Description;
                    quotationLocal.Tasks.Add(_taskLocal);
                }

                quotationLocal.Description = quotation.Description;

                quotationLocal.OrderDetails        = _OrderDetailsNueva;
                quotationLocal.ProviderArrivalDate = DateTime.Now;
                _OrderDetailsNueva.Status          = SD.EstadoCotizando;
                _quoationRepository.Add(quotationLocal);
                _orderDetailsRepository.Add(_OrderDetailsNueva);
            }
            try
            {
                _queries.SaveChanges();
            }
            catch (Exception ex)
            {
            }
            return(Ok());
        }