コード例 #1
0
        public static void approveOrder(ApprovedOrder order)
        {
            var credential = GetSheetCredentials();
            var service    = GetService(credential);

            SpreadsheetsResource.ValuesResource.GetRequest request = service.Spreadsheets.Values.Get(SpreadsheetId, $"{order.orderDate}");
            ValueRange response = request.Execute();

            var objectList = new List <object>();
            int position   = 0;

            for (int i = 0; i < response.Values.Count; i++)
            {
                if (order.id == response.Values[i][0].ToString())
                {
                    objectList.AddRange(response.Values[i]);
                    position = i;
                }
            }



            if (objectList.Count < 19)
            {
                objectList.Add(order.billId);
                objectList.Add(order.payDate);
                objectList.Add(order.sum);
            }
            else
            {
                objectList[17] = order.billId;
                objectList[18] = order.payDate;
                objectList[19] = order.sum;
            }

            var valueRange = new ValueRange();

            valueRange.Values = new List <IList <Object> > {
                objectList
            };

            var updateRequest = service.Spreadsheets.Values.Update(valueRange, SpreadsheetId, $"{order.orderDate}!A{position + 1}");

            updateRequest.ValueInputOption = SpreadsheetsResource.ValuesResource.UpdateRequest.ValueInputOptionEnum.USERENTERED;
            var updateRespinse = updateRequest.Execute();
        }
コード例 #2
0
        public void Put([FromBody] object value)
        {
            ApprovedOrder order = JsonSerializer.Deserialize <ApprovedOrder>(value.ToString());

            GoogleSheets.approveOrder(order);
        }
コード例 #3
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"));
        }