public async Task <Boolean> CleanReselleDates() { Boolean toreturn = false; List <voucher> voucherlist = (from c in db.vouchers select c).ToList(); foreach (voucher temp in voucherlist) { temp.voucherCreationDate = temp.voucherCreationDate.Value.AddMonths(-7); db.Entry(temp).State = EntityState.Modified; await db.SaveChangesAsync(); } return(toreturn); }
public async Task <IHttpActionResult> ProcessInsuranceProduct(ProcessedInsuranceProd prod) { activeproductitem temp = await db.activeproductitems.SingleAsync(c => c.product.ProductProvider_ID == prod.providerID && c.ActiveProductItems_ID == prod.activeproductID); Boolean toreturn = false; if (temp != null) { temp.isActive = true; temp.activeProductItemPolicyNum = prod.policyNo; await db.SaveChangesAsync(); toreturn = true; } return(Ok(toreturn)); }
public async Task <IHttpActionResult> Putproduct(int id, DTOproduct productDTO) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != productDTO.Product_ID) { return(BadRequest()); } var putProd = db.products.Single(e => e.Product_ID == id); db.Entry(EntityMapper.updateEntity(putProd, productDTO)).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!productExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <DTOclaim> Postclaim(DTOclaim newDTO) { claim newProd = EntityMapper.updateEntity(null, newDTO); db.claims.Add(newProd); await db.SaveChangesAsync(); return(newDTO); }
public async Task <IHttpActionResult> rejectConsumer(int userID) { try { user toReject = db.users.Find(userID); toReject.userActivationType = "Rejected"; await db.SaveChangesAsync(); NotificationController notification = new NotificationController(); string userNum = notification.getPhoneNumFromUserID(userID); notification.SendSMS(userNum, "Hello from NanoFin. We are sorry to inform you that your NanoFin application could not be processed. Please contact us at: [email protected] or visit us at: JoziHub - 44 Stanley Ave, Milpark, Johannesburg"); } catch (NullReferenceException) { return(BadRequest("User to reject not found.")); } return(Ok()); }
public async Task <Boolean> SetConsumerData() { Boolean toreturn = false; String[] gender = { "Male", "Female" }; Random r = new Random(); var list = db.consumers.ToList(); foreach (consumer temp in list) { //temp.gender = gender[r.Next() % 2]; //temp.maritalStatus = (r.Next(100) > 55) ? "Single" : "Married"; //temp.employmentStatus = (r.Next(100) > 80) ? "Unemplyed" : "Employed"; temp.numDependant = (r.Next(4)); //int gross = 1200 + (r.Next(3800)); //temp.grossMonthlyIncome = gross; //temp.nettMonthlyIncome = (Decimal) (1 + gross* 0.15) ; //temp.totalMonthlyExpenses = gross *(Decimal) 0.5; await db.SaveChangesAsync(); } toreturn = true; return(toreturn); }
public async Task <IHttpActionResult> putAdditionalSignUpInfo(int userID, string consumerAddress, string homeOwnerType, Nullable <int> numDependants, string topProductsInterestedIn, Nullable <decimal> grossMonthly, Nullable <decimal> nettMonthly, Nullable <decimal> totalExpenses) { consumer toUpdate = (from c in db.consumers where c.User_ID == userID select c).SingleOrDefault(); DTOconsumer dtoConsumer = new DTOconsumer(toUpdate); dtoConsumer.consumerAddress = consumerAddress; dtoConsumer.homeOwnerType = homeOwnerType; dtoConsumer.numDependant = numDependants; dtoConsumer.topProductCategoriesInterestedIn = topProductsInterestedIn; dtoConsumer.grossMonthlyIncome = grossMonthly; dtoConsumer.nettMonthlyIncome = nettMonthly; dtoConsumer.totalMonthlyExpenses = totalExpenses; toUpdate = EntityMapper.updateEntity(toUpdate, dtoConsumer); db.Entry(toUpdate).State = EntityState.Modified; await db.SaveChangesAsync(); return(StatusCode(HttpStatusCode.OK)); }
public async Task <DTOactiveproductitem> Postactiveproductitem(DTOactiveproductitem newDTO) { activeproductitem newProd = EntityMapper.updateEntity(null, newDTO); db.activeproductitems.Add(newProd); await db.SaveChangesAsync(); return(newDTO); }
public async Task <IHttpActionResult> putUser(int id, DTOusertype dtousertype) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != dtousertype.UserType_ID) { return(BadRequest()); } var putUsertype = db.usertypes.Single(e => e.UserType_ID == id); db.Entry(EntityMapper.updateEntity(putUsertype, dtousertype)).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!userExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }