コード例 #1
0
ファイル: Create.cshtml.cs プロジェクト: luanner88/agenciaPP
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }
            Contact.ContactId = Guid.NewGuid();
            Contact.CreatedAt = DateTime.Now;
            _context.Contact.Add(Contact);

            Phone phone = new Phone();

            phone.PhoneId     = Guid.NewGuid();
            phone.ReferenceId = Contact.ContactId;
            phone.Number      = Phone;
            phone.Current     = true;
            phone.Type        = "Fijo";
            _context.Add(phone);

            Phone movil = new Phone();

            movil.PhoneId     = Guid.NewGuid();
            movil.ReferenceId = Contact.ContactId;
            movil.Number      = Phone;
            movil.Current     = true;
            movil.Type        = "Movil";
            _context.Add(movil);


            Address address = new Address();

            address.AddressId    = Guid.NewGuid();
            address.ReferenceId  = Contact.ContactId;
            address.AddressLine1 = Address;
            address.City         = City;
            address.State        = State;
            address.Zip          = Zip;
            address.Country      = "Estados Unidos";
            address.Type         = "Oficina";
            address.CreatedAt    = DateTime.Now;
            address.CreatedBy    = _context.User.FirstOrDefault().UserId; //Ver Aqui va el usuario registrado
            address.UpdatedAt    = DateTime.Now;
            address.UpdatedBy    = _context.User.FirstOrDefault().UserId; //Ver Aqui va el usuario registrado
            _context.Add(address);


            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
コード例 #2
0
        public void CrearOrden(Guid contactId)
        {
            order              = new Order();
            order.OrderId      = Guid.NewGuid();
            order.Agency       = _context.Agency.First();
            order.AgencyId     = order.Agency.AgencyId;
            order.Office       = _context.Office.First();
            order.OfficeId     = order.Office.OfficeId;
            order.User         = _context.User.First();
            order.UserId       = _context.User.First().UserId;
            order.Date         = DateTime.Now.Date;
            order.TipoPago     = _context.TipoPago.First();
            order.TipoPagoId   = order.TipoPago.TipoPagoId;
            order.Type         = "Misto";
            order.Number       = "MX";
            order.Number      += DateTime.Now.ToString("MMddyyyyHHmm");
            order.ContactId    = contactId;
            order.ClientId     = _context.Contact.Find(order.ContactId).ClientId;
            order.Amount       = 0;
            order.ValorAduanal = 0;
            order.CantLb       = 0;
            order.PriceLb      = 0;
            order.OtrosCostos  = 0;
            order.Balance      = 0;
            order.ValorPagado  = 0;
            order.Status       = "Iniciada";
            _context.Add(order);
            _context.SaveChanges();

            //Crear un Pacquete
            Package package = new Package();

            package.PackageId         = Guid.NewGuid();
            package.PackageNavigation = order;
            _context.Add(package);
            order.Package = package;
            _context.SaveChanges();
        }
コード例 #3
0
ファイル: Create.cshtml.cs プロジェクト: luanner88/agenciaPP
        public IActionResult OnPost()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }
            Order.OrderId  = Guid.NewGuid();
            Order.Agency   = _context.Agency.First();
            Order.AgencyId = Order.Agency.AgencyId;
            Order.Office   = _context.Office.First();
            Order.OfficeId = Order.Office.OfficeId;
            Order.User     = _context.User.First();
            Order.UserId   = _context.User.First().UserId;
            Order.Date     = DateTime.Now.Date;

            Order.TipoPago   = _context.TipoPago.First();
            Order.TipoPagoId = Order.TipoPago.TipoPagoId;
            if (Order.Type == "Mixto")
            {
                Order.Number = "MX";
            }
            else if (Order.Type == "Paquete")
            {
                Order.Number = "PA";
            }
            else if (Order.Type == "Alimentos")
            {
                Order.Number = "AL";
            }
            else if (Order.Type == "Medicina")
            {
                Order.Number = "ME";
            }
            else
            {
                Order.Number = "RE";
            }
            Order.Number += DateTime.Now.ToString("MMddyyyyHHmm");

            if (listVA.Count() > 0)
            {
                for (int i = 0; i < listVA.Count(); i++)
                {
                    ValorAduanalItem value = new ValorAduanalItem();
                    value.ValorAduanalItemId = Guid.NewGuid();
                    value.OrderId            = Order.OrderId;
                    value.Order          = Order;
                    value.ValorAduanal   = _context.ValorAduanal.Where(x => x.ValorAduanalId == Guid.Parse(listVA[i])).First();
                    value.ValorAduanalId = Guid.Parse(listVA[i]);
                    Order.ValorAduanal  += value.ValorAduanal.Value;
                    Order.ValorAduanalItem.Add(value);
                    _context.Add(value);
                }
            }

            Order.Amount  = Order.ValorAduanal + (Order.CantLb * Order.PriceLb) + Order.OtrosCostos;
            Order.Balance = Order.Amount - Order.ValorPagado;
            if (Order.Balance != 0)//si el balance no es 0 el status es pendiente si el valanece es 0 iniciado,
            {
                Order.Status = "Pendiente";
            }
            else
            {
                Order.Status = "Iniciada";
            }
            Order.ContactId = contactId;
            Order.ClientId  = _context.Contact.Find(Order.ContactId).ClientId;
            _context.Add(Order);


            //Crear un Pacquete
            Package package = new Package();

            package.PackageId         = Guid.NewGuid();
            package.PackageNavigation = Order;
            _context.Add(package);

            if (PackageItem.Count > 0)
            {
                for (int i = 0; i < listProduct.Count; i++)
                {
                    PackageItem packageItem = new PackageItem();
                    packageItem.PackageItemId = Guid.NewGuid();
                    packageItem.PackageId     = pac.PackageId;
                    packageItem.Package       = pac;
                    packageItem.Product       = _context.Product.Where(x => x.ProductId == Guid.Parse(listProduct[i])).First();
                    packageItem.ProductId     = packageItem.Product.ProductId;
                    _context.PackageItem.Add(packageItem);
                }
            }

            Order.Package = package;
            _context.SaveChanges();

            return(RedirectToPage("/Index"));
        }
コード例 #4
0
        public void CrearOrden()
        {
            order          = new Order();
            order.OrderId  = Guid.NewGuid();
            order.Agency   = _context.Agency.First();
            order.AgencyId = order.Agency.AgencyId;
            order.Office   = _context.Office.First();
            order.OfficeId = order.Office.OfficeId;
            order.User     = _context.User.First();
            order.UserId   = _context.User.First().UserId;
            order.Date     = DateTime.Now.Date;

            //order.TipoPago = _context.TipoPago.First();
            //order.TipoPagoId = order.TipoPago.TipoPagoId;
            order.Type = type;
            if (type == "Mixto")
            {
                order.Number = "MX";
            }
            else if (type == "Paquete")
            {
                order.Number = "PA";
            }
            else if (type == "Alimentos")
            {
                order.Number = "AL";
            }
            else if (type == "Medicina")
            {
                order.Number = "ME";
            }
            else
            {
                order.Number = "RE";
            }
            order.Number += DateTime.Now.ToString("MMddyyyyHHmm");

            if (listVA.Count() > 0)
            {
                for (int i = 0; i < listVA.Count(); i++)
                {
                    ValorAduanalItem value = new ValorAduanalItem();
                    value.ValorAduanalItemId = Guid.NewGuid();
                    value.OrderId            = order.OrderId;
                    value.Order          = order;
                    value.ValorAduanal   = _context.ValorAduanal.Where(x => x.ValorAduanalId == Guid.Parse(listVA[i])).First();
                    value.ValorAduanalId = Guid.Parse(listVA[i]);
                    order.ValorAduanal  += value.ValorAduanal.Value;
                    order.ValorAduanalItem.Add(value);
                    _context.Add(value);
                }
            }



            order.CantLb       = cantlb;
            order.PriceLb      = preciolb;
            order.OtrosCostos  = otrosgastos;
            order.ValorAduanal = valor;
            order.Amount       = order.ValorAduanal + (order.CantLb * order.PriceLb) + order.OtrosCostos;
            order.Balance      = order.Amount - order.ValorPagado;
            if (order.Balance != 0)//si el balance no es 0 el status es pendiente si el valanece es 0 iniciado,
            {
                order.Status = "Pendiente";
            }
            else
            {
                order.Status = "Iniciada";
            }
            order.ContactId = contactId;
            order.ClientId  = _context.Contact.Find(order.ContactId).ClientId;
            _context.Add(order);
            _context.SaveChanges();

            //Crear un Pacquete
            Package package = new Package();

            package.PackageId         = Guid.NewGuid();
            package.PackageNavigation = order;
            _context.Add(package);

            for (int i = 0; i < listProduct.Count; i++)
            {
                PackageItem packageItem = new PackageItem();
                packageItem.PackageItemId = Guid.NewGuid();
                packageItem.PackageId     = pac.PackageId;
                packageItem.Package       = pac;
                packageItem.Product       = _context.Product.Where(x => x.ProductId == Guid.Parse(listProduct[i])).First();
                packageItem.ProductId     = packageItem.Product.ProductId;
                _context.Add(packageItem);
            }
            order.Package = package;
            _context.SaveChanges();
        }