Пример #1
0
        public AddCompanyResponse addCompIndvidualModel(AddCompanyIndPayload comp, IConfiguration _config, IHostingEnvironment env)
        {
            try
            {
                using (var db = new TrippleNTDBContext())
                {
                    var checkcompany = db.Company.Where(o => o.PhoneNumber == comp.phoneNumber || o.Email == comp.email || o.Rcno == comp.rcNo).FirstOrDefault();
                    if (checkcompany != null)
                    {
                        return(checkcompany.PhoneNumber == comp.phoneNumber? new AddCompanyResponse {
                            status = "failed", msg = "Phone Number  Already Exists"
                        } :comp.rcNo == checkcompany.Rcno ? new AddCompanyResponse {
                            status = "failed", msg = "Invalid Company Reg Number"
                        }: new AddCompanyResponse {
                            status = "failed", msg = "Email Already Exists"
                        });
                    }
                    var newcomp = new Company();
                    newcomp.Name        = comp.companyName;
                    newcomp.Email       = comp.email;
                    newcomp.PhoneNumber = comp.phoneNumber;
                    newcomp.Type        = 1;
                    newcomp.RegDate     = DateTime.Now;
                    newcomp.Location    = comp.location;
                    newcomp.State       = comp.state;
                    db.Company.Add(newcomp);
                    db.SaveChanges();
                    var password = comp.password;
                    var staff    = new CompanyStaff();
                    staff.CompanyId   = newcomp.CompanyId;
                    staff.DateCreated = DateTime.Now;
                    staff.UseStatus   = false;
                    staff.Password    = Utility.Encryptor.EncodePasswordMd5(password);
                    staff.UserType    = "Admin";
                    db.CompanyStaff.Add(staff);
                    var staff1 = new CompanyStaff();
                    staff.CompanyId    = newcomp.CompanyId;
                    staff1.DateCreated = DateTime.Now;
                    staff1.UseStatus   = false;
                    staff1.Password    = Utility.Encryptor.GeneratePassword(6);
                    staff1.UserType    = "User";
                    db.CompanyStaff.Add(staff);
                    db.SaveChanges();
                    var msg = "Hello, " + comp.companyName + ", <br> We are glad to have you on our EduFund crowdfunding Platform. <br> Kindly See your credentials below <br><b>User Id: " + newcomp.PhoneNumber + "</b><br> <b>  Password: "******"  </b><br><br>#ChangeTheWorldWithYourSpareChange <br><br>Regards,<br> Admin Edufund";
                    Utility.SendMail.Send("Welcome to EduFund", msg, newcomp.Email, _config);


                    return(new AddCompanyResponse {
                        status = "success", msg = "Company Created Successfully"
                    });
                }
            }
            catch (Exception ex)
            {
                new Utility.LogWriter(ex.Message + " " + ex.InnerException, env);
                return(new AddCompanyResponse {
                    status = "failed", msg = "Something Went Wrong Try again Later"
                });
            }
        }
Пример #2
0
        public donateResponse donate(donatePayload donate, IConfiguration _config, IHostingEnvironment env)
        {
            try
            {
                using (var db = new TrippleNTDBContext()) {
                    var reco = db.Reconciliation.Where(o => o.CompanyId == donate.companyId && o.Status == "Pending").FirstOrDefault();
                    if (reco != null)
                    {
                        return new donateResponse {
                                   status = "failed", msg = "Cannot commit donations becuase you have pending reconcilation payment "
                        }
                    }
                    ;
                    var donation = new Donations();
                    donation.DateDonated    = DateTime.Now;
                    donation.CompanyStaffId = donate.userId;
                    donation.ComapanyId     = donate.companyId;
                    donation.Amount         = donate.amount;
                    donation.Donor          = donate.phoneNumber;
                    donation.Status         = "NR";
                    db.Donations.Add(donation);
                    db.SaveChanges();
                    var donor = db.Donors.Find(donate.phoneNumber);
                    if (donor == null)
                    {
                        var d = new Donors();

                        d.PhoneNumber = donate.phoneNumber;
                        db.Donors.Add(d);
                        db.SaveChanges();
                    }
                    var msg = "Hello, thank you for your donation, Edufund appreciates your commitment to changing the world with your 'SPARE CHANGE'. Your can view your donation badge here https://bit.ly/fRruwQE";
                    var a   = SendSMS.Send(donate.phoneNumber, msg, _config);
                    return(new donateResponse {
                        status = "success", msg = "Donation was Successful. Thank You"
                    });
                }
            }
            catch (Exception ex)
            {
                new Utility.LogWriter(ex.Message + " " + ex.InnerException, env);
                return(new donateResponse {
                    status = "failed", msg = "Something went wrong try again Later"
                });
            }
        }
Пример #3
0
 public PaymentResponse NewRecord(PaymentPayload rcd)
 {
     try
     {
         using (var db = new TrippleNTDBContext())
         {
             var reco = db.Reconciliation.Find(rcd.ReconcileId);
             if (reco == null)
             {
                 return new PaymentResponse {
                            status = "failed", msg = "Reconciliation ID not Found"
                 }
             }
             ;
             var p = new Payments();
             p.ReconcileId   = rcd.ReconcileId;
             p.Reference     = rcd.Reference;
             p.DateOfPayment = DateTime.Now;
             p.UserId        = rcd.UserId;
             p.CompanyId     = rcd.CompanyId;
             p.Amount        = rcd.amount;
             db.Payments.Add(p);
             reco.Status = "Paid";
             db.Reconciliation.Attach(reco);
             db.Entry(reco).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
             db.SaveChanges();
             var lstunreco = db.Donations.Where(o => o.ComapanyId == rcd.CompanyId && o.DateDonated.Date <= reco.EndPeriod.Date && o.Status == "NR").ToList();
             lstunreco.ForEach(o => o.Status = "R");
             db.SaveChanges();
             return(new PaymentResponse {
                 status = "success", msg = "Payment Successful"
             });
         }
     }
     catch (Exception ex)
     {
         return(new PaymentResponse {
             status = "failed", msg = "Something went wrong try again later"
         });
     }
 }
Пример #4
0
 public object NewRecord(Reconciliation rcd)
 {
     try
     {
         using (var db = new TrippleNTDBContext())
         {
             db.Reconciliation.Add(rcd);
             db.SaveChanges();
             return(new reconcileResponse {
                 value = 1
             });
         }
     }
     catch (Exception ex)
     {
         return(new reconcileResponse {
             value = 0
         });
     }
 }