public IHttpActionResult InstallmentRequestStatusUpdate(int id, int status)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Invalid data."));
            }

            string currentUserId          = User.Identity.GetUserId();
            LoanAndRepayEntities entities = new LoanAndRepayEntities();


            using (entities)
            {
                var req = entities.InstallmentRequests.Where(x => x.Id == id).SingleOrDefault();

                if (status == 1 && req != null)
                {
                    req.Status = status;
                    entities.SaveChanges();
                }
                else if (status == 2 && req != null)
                {
                    req.Status = status;
                    entities.SaveChanges();
                }
            }

            return(Ok());
        }
Beispiel #2
0
        public static void SaveInstallmentRequest(InstallmentRequestViewModel model, string UserId)
        {
            LoanAndRepayEntities entities           = new LoanAndRepayEntities();
            InstallmentRequest   installmentRequest = new InstallmentRequest();

            DAL.Address address = new DAL.Address();

            //First saves the installment request information in the installment table
            installmentRequest.UserId         = UserId;
            installmentRequest.Company        = model.Company;
            installmentRequest.FirstName      = model.FirstName;
            installmentRequest.LastName       = model.LastName;
            installmentRequest.Email          = model.Email;
            installmentRequest.Age            = model.Age;
            installmentRequest.Phone          = model.Phone;
            installmentRequest.Amount         = model.Amount;
            installmentRequest.PayWithIn      = model.PayWithIn;
            installmentRequest.MonthlyPayment = model.MonthlyPayment;
            installmentRequest.Status         = model.Status;
            entities.InstallmentRequests.Add(installmentRequest);
            entities.SaveChanges();
            var checkExistingInstallment = entities.InstallmentRequests.Where(x => x.Company == model.Company && x.Email == model.Email).FirstOrDefault();

            //Then saves the installment request address in the address table
            address.StreetName  = model.StreetName;
            address.HouseNumber = model.HouseNumber;
            address.CityName    = model.CityName;
            address.PostCode    = model.PostCode;

            address.InstallmentId = checkExistingInstallment.Id;
            entities.Addresses.Add(address);
            entities.SaveChanges();
        }
Beispiel #3
0
        public static void SaveCompanyInfo(RegisterCompanyBindingModel registerCompanyModel, string userId)
        {
            LoanAndRepayEntities database = new LoanAndRepayEntities();

            CompanyInfo companyInfo = new CompanyInfo();

            DAL.Address address = new DAL.Address();
            if (companyInfo != null)
            {
                //First saves the company information in the company table
                companyInfo.UserId      = userId;
                companyInfo.CompanyName = registerCompanyModel.CompanyName;
                companyInfo.CVR         = registerCompanyModel.CVR;
                companyInfo.Email       = registerCompanyModel.Email;
                companyInfo.Phone       = registerCompanyModel.Phone;
                database.CompanyInfoes.Add(companyInfo);

                //Then saves the company address in the address table
                address.StreetName  = registerCompanyModel.StreetName;
                address.HouseNumber = registerCompanyModel.HouseNumber;
                address.CityName    = registerCompanyModel.CityName;
                address.PostCode    = registerCompanyModel.PostCode;
                address.UserId      = userId;
                database.Addresses.Add(address);
                database.SaveChanges();
            }
        }
Beispiel #4
0
        public static void CreateUser(RegisterBindingModel registerBindingModel)
        {
            LoanAndRepayEntities entities = new LoanAndRepayEntities();
            AspNetUser           user     = entities.AspNetUsers.SingleOrDefault(x => x.Email == registerBindingModel.Email);

            if (user != null)
            {
                user.FirstName   = registerBindingModel.FirstName;
                user.LastName    = registerBindingModel.LastName;
                user.PhoneNumber = registerBindingModel.PhoneNumber;
                user.Email       = registerBindingModel.Email;

                entities.SaveChanges();
            }
        }