Ejemplo n.º 1
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var state = new State {
                Statecode = Input.StateCode, Statename = Input.StateName
            };

            _context.Add(state);
            await _context.SaveChangesAsync();


            return(RedirectToPage("./Success"));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> OnPostAsync(ICollection <IFormFile> files)
        {
            if (string.IsNullOrWhiteSpace(_hostingEnvironment.WebRootPath))
            {
                _hostingEnvironment.WebRootPath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot");
            }

            //string rootpath = _hostingEnvironment.WebRootPath;
            string uploads = Path.Combine(_hostingEnvironment.WebRootPath, "Uploads");

            foreach (var fil in files)
            {
                if (fil.Length > 0)
                {
                    using (var fileStream = new FileStream(Path.Combine(uploads, fil.FileName), FileMode.Create))
                    {
                        await fil.CopyToAsync(fileStream);
                    }
                }
            }
            string fileName      = "NGALGA.xlsx";
            string newrootFolder = uploads + "/" + fileName;

            FileInfo file = new FileInfo(newrootFolder);

            using (ExcelPackage package = new ExcelPackage(file))
            {
                ExcelWorksheet workSheet = package.Workbook.Worksheets["LGA"];
                int            totalRows = workSheet.Dimension.Rows;

                for (int i = 2; i <= totalRows; i++)
                {
                    var lgalist = new Lga(workSheet.Cells[i, 1].Value.ToString(), int.Parse(workSheet.Cells[i, 2].Value.ToString()));
                    _context.Add(lgalist);
                }

                await _context.SaveChangesAsync();

                return(RedirectToPage("./Success"));
            }
            return(null);
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> OnPostSaveAgentAsync()
        {
            string merchantid = "";
            var    builder    = new ConfigurationBuilder()
                                .SetBasePath(Directory.GetCurrentDirectory())
                                .AddJsonFile("appsettings.json");
            var    configuration = builder.Build();
            string paendpoint    = configuration["payattititudeendpoint"];
            //
            var random = new Random();
            var tid    = PhoneNumber.Substring(3, 8) + BusinessName.Substring(0, 3).ToUpper() + DateTime.Now.ToString("ddMMyyHHmmss");
            //var normed = Regex.Replace(tid, @"\s+", "");
            var normed = tid.Replace(" ", String.Empty);

            Transactionid = normed;
            double totalamt = 5000.00 * Double.Parse(noofselectedlgas);
            var    am       = totalamt.ToString("0.00");
            //
            Pwpresponse response = new Pwpresponse();
            Pwprequest  payload  = new Pwprequest()
            {
                Description = "UP AGENT REGISTRATION FEE",
                TrxId       = normed,
                Amount      = am,
                Phone       = PhoneNumber
            };
            var despayload = JsonConvert.SerializeObject(payload);

            //ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, errors) => {
            //    return true;
            //};
            //ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
            HttpClient client = CreateWebRequest();

            var resp = await client.PostAsJsonAsync(paendpoint, payload);

            if (!resp.IsSuccessStatusCode)
            {
                //SuccessResponse response = new SuccessResponse {
                response.status       = null;
                response.amount       = null;
                response.approvalCode = null;
                response.date         = DateTime.Now.ToString();
                response.holder       = null;
                response.id           = null;
                response.paymentRef   = null;
                response.requestId    = null;
                response.existing     = null;
                response.phone        = null;
                response.success      = null;
                response.uan          = null;
                MutantStatus          = "A network error occured, Please try again";
                return(Page());
            }
            else
            {
                var readResult = await resp.Content.ReadAsStringAsync();

                var dresult = (Pwpresponse)JsonConvert.DeserializeObject(readResult, typeof(Pwpresponse));

                response.status       = dresult.status;
                response.amount       = dresult.amount;
                response.approvalCode = dresult.approvalCode;
                response.date         = dresult.date;
                response.holder       = dresult.holder;
                response.id           = dresult.id;
                response.paymentRef   = dresult.paymentRef;
                response.requestId    = dresult.requestId;
                response.existing     = dresult.existing;
                response.phone        = dresult.phone;
                response.success      = dresult.success;
                response.uan          = dresult.uan;

                if (response.success == "true")
                {
                    try
                    {
                        successstatus = response.success;
                        var agent = new Upagent
                        {
                            Phonenumber         = PhoneNumber,
                            Businessname        = BusinessName,
                            Businessphone       = BusinessPhoneNumber,
                            Selectedproprietors = JSONproprietors,
                            Businessemail       = BusinessEmail,
                            Officeaddress       = Address,
                            Officestateid       = Officestateid,
                            Officelgaid         = Officelgaid,
                            Acctypeid           = 2,
                            Rcnumber            = RCNumber,
                            Natureofbusiness    = NatureofBusiness,
                            Noofbusinessyears   = NoofBusinessYears,
                            Deslgaid            = Deslgaid,
                            Turnover            = Turnover,
                            Profitbeforetax     = ProfitBeforeTax,
                            Selectedlgas        = JSONLGAs,
                            invoiceNumber       = normed,
                            PATransactionid     = dresult.paymentRef,
                            PaymentStatus       = "1",
                            Trandate            = DateTime.Now.ToString()
                        };
                        _context.Add(agent);
                        await _context.SaveChangesAsync();

                        return(RedirectToPage("./Success"));
                    }
                    catch (Exception e) { }
                }
                else
                {
                    var agent = new Upagent
                    {
                        Phonenumber         = PhoneNumber,
                        Businessname        = BusinessName,
                        Businessphone       = BusinessPhoneNumber,
                        Selectedproprietors = JSONproprietors,
                        Businessemail       = BusinessEmail,
                        Officeaddress       = Address,
                        Officestateid       = Officestateid,
                        Officelgaid         = Officelgaid,
                        Acctypeid           = 2,
                        Rcnumber            = RCNumber,
                        Natureofbusiness    = NatureofBusiness,
                        Noofbusinessyears   = NoofBusinessYears,
                        Deslgaid            = Deslgaid,
                        Turnover            = Turnover,
                        Profitbeforetax     = ProfitBeforeTax,
                        Selectedlgas        = JSONLGAs,
                        invoiceNumber       = normed,
                        PATransactionid     = dresult.paymentRef,
                        PaymentStatus       = "0",
                        Trandate            = DateTime.Now.ToString(),
                    };
                    _context.Add(agent);
                    await _context.SaveChangesAsync();

                    StateList = _context.State.Select(a =>
                                                      new SelectListItem
                    {
                        Value = a.Id.ToString(),
                        Text  = a.Statename
                    }).ToList();

                    LGAList = _context.Lga.Select(a =>
                                                  new SelectListItem
                    {
                        Value = a.Id.ToString(),
                        Text  = a.Lganame
                    }).ToList();
                    Transactionid = null;
                    MutantStatus  = dresult.status;
                    return(Page());
                }

                StateList = _context.State.Select(a =>
                                                  new SelectListItem
                {
                    Value = a.Id.ToString(),
                    Text  = a.Statename
                }).ToList();

                LGAList = _context.Lga.Select(a =>
                                              new SelectListItem
                {
                    Value = a.Id.ToString(),
                    Text  = a.Lganame
                }).ToList();
                return(Page());
            }
        }