コード例 #1
0
        public IHttpActionResult CreateApprovedOrders(ApprovedOrderDto approvedOrderDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var approvedOrder = Mapper.Map <ApprovedOrderDto, ApprovedOrder>(approvedOrderDto);

            _context.ApprovedOrders.Add(approvedOrder);
            _context.SaveChanges();

            approvedOrderDto.Id = approvedOrder.Id;

            return(Created(new Uri(Request.RequestUri + "/" + approvedOrder.Id), approvedOrderDto));
        }
コード例 #2
0
        public ActionResult Details(Order order, HttpPostedFileBase uploadPassportImage, HttpPostedFileBase uploadINNImage)
        {
            byte[] imagePassport = null;
            if (uploadPassportImage != null)
            {
                using (var binaryReader = new BinaryReader(uploadPassportImage.InputStream))
                {
                    imagePassport = binaryReader.ReadBytes(uploadPassportImage.ContentLength);
                }
                order.PassportImages = imagePassport;
            }

            byte[] imageINN = null;
            if (uploadINNImage != null)
            {
                using (var binaryReader = new BinaryReader(uploadINNImage.InputStream))
                {
                    imageINN = binaryReader.ReadBytes(uploadINNImage.ContentLength);
                }
                order.INNImages = imageINN;
            }

            var orderInDb = _context.Orders.SingleOrDefault(o => o.Id == order.Id);

            if (Request.Form["approve"] != null)
            {
                order.OrderStatus  = "Підтверджено";
                order.ApprovedDate = DateTime.Now.Date;

                ApprovedOrder approvedOrder = new ApprovedOrder();

                approvedOrder.Amount              = order.Amount;
                approvedOrder.LoanPeriod          = order.LoanId;
                approvedOrder.LastName            = order.LastName;
                approvedOrder.FirstName           = order.FirstName;
                approvedOrder.FathersName         = order.FathersName;
                approvedOrder.DateOfBirth         = order.DateOfBirth;
                approvedOrder.Email               = order.Email;
                approvedOrder.PhoneNumber         = order.PhoneNumber;
                approvedOrder.INN                 = order.INN;
                approvedOrder.PassportNumber      = order.PassportNumber;
                approvedOrder.PassportGivenByWhom = order.PassportGivenByWhom;
                approvedOrder.PassportGivenDate   = order.PassportGivenDate;
                approvedOrder.CardNumber          = order.CardNumber;
                approvedOrder.OrderStatus         = order.OrderStatus;
                approvedOrder.ApprovedDate        = order.ApprovedDate;
                approvedOrder.UnionName           = UnionName;

                _contextUnions.ApprovedOrders.Add(approvedOrder);
                _contextUnions.SaveChanges();
            }
            else if (Request.Form["decline"] != null)
            {
                order.OrderStatus  = "Відмовлено";
                order.ApprovedDate = DateTime.Now.Date;
            }

            orderInDb.Amount              = order.Amount;
            orderInDb.LoanId              = order.LoanId;
            orderInDb.LastName            = order.LastName;
            orderInDb.FirstName           = order.FirstName;
            orderInDb.FathersName         = order.FathersName;
            orderInDb.DateOfBirth         = order.DateOfBirth;
            orderInDb.Email               = order.Email;
            orderInDb.PhoneNumber         = order.PhoneNumber;
            orderInDb.INN                 = order.INN;
            orderInDb.PassportNumber      = order.PassportNumber;
            orderInDb.PassportGivenByWhom = order.PassportGivenByWhom;
            orderInDb.PassportGivenDate   = order.PassportGivenDate;
            orderInDb.PassportImages      = order.PassportImages;
            orderInDb.INNImages           = order.INNImages;
            orderInDb.CreationDate        = order.CreationDate;
            orderInDb.CardNumber          = order.CardNumber;
            orderInDb.OrderStatus         = order.OrderStatus;
            orderInDb.ApprovedDate        = order.ApprovedDate;

            _context.SaveChanges();

            return(RedirectToAction("Index", "Orders"));
        }