public ActionResult ChangePrimary(string phone_number) { string delete_status = FreebieStatus.MobileDeleted(); AccountMobile am = db.AccountMobiles.Where(x => x.Mobile_Number.Equals(phone_number)).Where(x => !x.Status_Cd.Equals(delete_status)).SingleOrDefault(); if (am == null) { return(HttpNotFound()); } int account_id = am.Account_Id; Account account = db.Accounts.SingleOrDefault(x => x.Account_Id == account_id); IEnumerable <AccountMobile> account_numbers = db.AccountMobiles.Where(x => x.Account_Id.Equals(account_id)).Where(x => !x.Status_Cd.Equals(delete_status)); foreach (var number in account_numbers) { if (number.Mobile_Number.Equals(phone_number)) { number.Primary_Flag = true; } else { number.Primary_Flag = false; } number.Updated_By = System.Configuration.ConfigurationManager.AppSettings["SystemUsername"]; number.Updated_Dttm = DateTime.Now; } db.SaveChanges(); FreebieEvent.UpdateMobile(account, phone_number, "A04", Permission.f_update_number_page_id); return(RedirectToAction("ViewNumber", "AccInfo")); }
public ActionResult RemoveNumber(string phone_number) { string delete_status = FreebieStatus.MobileDeleted(); AccountMobile am = db.AccountMobiles.Where(x => x.Mobile_Number.Equals(phone_number)).Where(x => !x.Status_Cd.Equals(delete_status)).SingleOrDefault(); if (am == null) { return(HttpNotFound()); } else { // db.AccountMobiles.Remove(am); am.Status_Cd = FreebieStatus.MobileDeleted(); am.Updated_By = System.Configuration.ConfigurationManager.AppSettings["SystemUsername"]; am.Updated_Dttm = DateTime.Now; db.SaveChanges(); FreebieEvent.UpdateMobile(am.Account, phone_number, "A05", Permission.f_update_number_page_id); } return(RedirectToAction("ViewNumber", "AccInfo")); }
public ActionResult AddNumber(string phoneNumber) { string password = Request.Form["Password"]; phoneNumber = GetCookie("Acct", "phone_number"); bool flag = true; if (string.IsNullOrEmpty(phoneNumber)) { ViewBag.ValidNumber = false; ViewBag.PhoneNumber = ""; flag = false; } ViewBag.PhoneNumber = phoneNumber; string otp = Request.Form["Password"]; if (flag && (string.IsNullOrEmpty(otp) || otp.Length < 4)) { ViewBag.ValidNumber = true; ViewBag.Error = true; ViewBag.ErrorMessage = System.Configuration.ConfigurationManager.AppSettings["Validate010"]; flag = false; } if (flag) { int result = OTPHandler.ValidateOTP(phoneNumber, otp); switch (result) { case 0: int account_id = Convert.ToInt32(Session["Account_Id"].ToString()); var account = db.Accounts.SingleOrDefault(x => x.Account_Id == account_id); if (account == null) { return(HttpNotFound()); } AccountMobile am = db.AccountMobiles.Where(x => x.Account_Id.Equals(account.Account_Id)).Where(x => x.Mobile_Number.Equals(phoneNumber)).SingleOrDefault(); bool first_create = false; if (am == null) { am = new AccountMobile(); am.Account_Id = account.Account_Id; am.Status_Cd = FreebieStatus.MobileActive(); am.Mobile_Number = phoneNumber; am.Primary_Flag = false; am.Created_Dttm = DateTime.Now; am.Updated_Dttm = DateTime.Now; first_create = true; } if (first_create) { db.AccountMobiles.Add(am); } else { am.Status_Cd = FreebieStatus.MobileActive(); am.Created_Dttm = DateTime.Now; am.Updated_Dttm = DateTime.Now; db.Entry(am).State = EntityState.Modified; } OTP otp_request = db.OTPs.SingleOrDefault(x => x.PhoneNumber.Equals(phoneNumber)); if (otp_request != null) { db.OTPs.Remove(otp_request); } db.SaveChanges(); FreebieEvent.UpdateMobile(account, phoneNumber, "A03", Permission.f_update_number_page_id); RemoveCoookie("Acct"); return(RedirectToAction("ViewNumber", "AccInfo")); case 1: ViewBag.Error = true; ViewBag.ValidNumber = true; ViewBag.ErrorMessage = System.Configuration.ConfigurationManager.AppSettings["Validate007"]; ViewBag.ShowPwd = true; break; case 2: ViewBag.ValidNumber = false; ViewBag.PhoneNumber = ""; ViewBag.ResetOTP = System.Configuration.ConfigurationManager.AppSettings["Otp03"]; RemoveCoookie("Acct"); break; case 3: ViewBag.ValidNumber = false; ViewBag.PhoneNumber = ""; ViewBag.ResetOTP = System.Configuration.ConfigurationManager.AppSettings["Otp04"]; RemoveCoookie("Acct"); break; default: break; } } ViewBag.ShowPwd = true; return(View()); }