public HttpResponseMessage BumpClaimCount(string id) { // add 1 to count of claims for customer. CustomerDBConnect customerDBConnect = new CustomerDBConnect(); var cust = from c in customerDBConnect.Custs where c.CustomerID == id select c; Cust rCust = new Cust(); foreach (var cus in cust) { cus.ClaimCount++; rCust = cus; } customerDBConnect.SaveChanges(); string output = JsonConvert.SerializeObject(rCust); return(new HttpResponseMessage() { Content = new StringContent(output, Encoding.UTF8, "application/json"), StatusCode = HttpStatusCode.Created }); }
public HttpResponseMessage Put([FromBody] Cust cust) { // Update Customer CustomerDBConnect customerDbConnect = new CustomerDBConnect(); var cus = from c in customerDbConnect.Custs where c.CustomerID == cust.CustomerID select c; foreach (var u in cus) { u.CustomerID = cust.CustomerID; u.Encrypted = Security.cry(cust.Password, 1); u.Password = "******"; u.FirstName = cust.FirstName; u.LastName = cust.LastName; u.Email = cust.Email; u.Phone = cust.Phone; u.Address1 = cust.Address1; u.Address2 = cust.Address2; u.City = cust.City; u.State = cust.State; u.Zip = cust.Zip; u.ClaimCount = cust.ClaimCount; u.PolicyName = cust.PolicyName; u.PolicyID = cust.PolicyID; u.PromotionCode = cust.PromotionCode; } customerDbConnect.SaveChanges(); string output = JsonConvert.SerializeObject(cust); return(new HttpResponseMessage() { Content = new StringContent(output, Encoding.UTF8, "application/json"), StatusCode = HttpStatusCode.Created }); }
public ActionResult ResetPassword(ResetPassword resetPassword) { if (!ModelState.IsValid) { return(View()); } if (!Security.pwReset(resetPassword.Password)) { ViewBag.Message = "Unathorized attempt to reset password."; return(View()); } // validate customer id supplied. CustomerDBConnect customerDBConnect = new CustomerDBConnect(); var cust = from c in customerDBConnect.Customers where c.CustomerID == resetPassword.CustomerID select c; bool valid = false; foreach (var c in cust) { valid = true; } if (!valid) { ViewBag.Message = "Customer ID not found."; return(View()); } // update the password foreach (var item in cust) { item.Encrypted = Security.cry(Security.GetTemp(), 1); item.CustomerPassword = "******"; } customerDBConnect.SaveChanges(); ViewBag.Message = "Password Reset"; resetPassword.Password = ""; resetPassword.CustomerID = ""; return(View()); }
public ActionResult RegisterCustomer(Customer customer) { if (ModelState.IsValid == false) { return(View()); // show errors } ViewBag.Message = ""; if (customer.CustomerPassword.Length < 6) { // ViewBag.Message = "Password should be at least six charaters."; } CustomerDBConnect context = new CustomerDBConnect(); var message = CustomerEdits(context, customer); if (message != "") { ViewBag.Message = message; return(View()); } if (!Security.cryPromtionCode(customer.PromotionCode)) { ViewBag.Message = "Unauthorized access - promotion code required."; return(View()); } customer.Encrypted = Security.cry(customer.CustomerPassword, 1); customer.CustomerPassword = "******"; context.Customers.Add(customer); context.SaveChanges(); // store for assign policy screen. Session["CustomerID"] = customer.CustomerID; return(View("RegisterSuccess")); }
public ActionResult AssignPolicy(int?id) { if (id == null) { return(View()); } //find customer var inputCustID = Session["CustomerID"].ToString(); CustomerDBConnect customerDBConnect = new CustomerDBConnect(); var cust = from c in customerDBConnect.Customers where c.CustomerID == inputCustID select c; foreach (var item in cust) { item.PoicyID = (int)id; } customerDBConnect.SaveChanges(); return(RedirectToAction("CustomerReview")); }
public ActionResult CustomerReview(Customer customer) { if (ModelState.IsValid == false) { return(View()); // show errors } ViewBag.Message = ""; if (customer.CustomerPassword.Length < 6) { //ViewBag.Message = "Password should be at least six charaters."; } CustomerDBConnect customerDBConnect = new CustomerDBConnect(); var cust = from c in customerDBConnect.Customers where c.CustomerID == customer.CustomerID select c; foreach (var item in cust) { item.FirstName = customer.FirstName; item.LastName = customer.LastName; item.Encrypted = Security.cry(customer.CustomerPassword, 1); item.CustomerPassword = "******"; item.Email = customer.Email; item.Address1 = customer.Address1; item.Address2 = customer.Address2; item.City = customer.City; item.State = customer.State; item.Zip = customer.Zip; item.Phone = customer.Phone; } customerDBConnect.SaveChanges(); ViewBag.Message = "Update Successful."; return(View()); }
public HttpResponseMessage Post([FromBody] Cust cust) { // add customer try { string output = ""; // add customer CustomerDBConnect customerDbConnect = new CustomerDBConnect(); // duplicate check bool dupCust = false; var dup = from c in customerDbConnect.Custs where c.CustomerID == cust.CustomerID select c; foreach (var cDup in dup) { dupCust = true; } if (dupCust) { cust.CustomerID = "Duplicate Customer"; output = JsonConvert.SerializeObject(cust); return(new HttpResponseMessage() { Content = new StringContent(output, Encoding.UTF8, "application/json"), StatusCode = HttpStatusCode.Created }); } // ready to add if first '1' custID prime databases. // when cutomer number one is added load the // poicy and service databases. if (cust.CustomerID == "1") { Loader loader = new Loader(); loader.PolicyLoader(); loader.LoadServices(); } cust.Encrypted = Security.cry(cust.Password, 1); cust.Password = "******"; customerDbConnect.Custs.Add(cust); customerDbConnect.SaveChanges(); output = JsonConvert.SerializeObject(cust); return(new HttpResponseMessage() { Content = new StringContent(output, Encoding.UTF8, "application/json"), StatusCode = HttpStatusCode.Created }); } catch (System.Exception ex) { string theMessage = "[ Error creating customer ] " + ex.ToString(); return(new HttpResponseMessage() { Content = new StringContent(theMessage, Encoding.UTF8, "application/json"), StatusCode = HttpStatusCode.BadRequest }); } }