public ActionResult HandleRazorPay(string deviceId) { using (eponym_app_licenseEntities db = new eponym_app_licenseEntities()) { var loggedInUser = (UserCredentials)(Session["UserCredentials"]); if (loggedInUser != null) { var algo = db.AlgoExpiries.FirstOrDefault(x => x.CustomerID == loggedInUser.Id); if (algo == null) { algo = new AlgoExpiry() { CustomerID = loggedInUser.Id, DeviceID = deviceId, DateExpiry = DateTime.Now.AddDays(7).ToString("dd-MM-yyyy"), AppName = "Default", MaxUser = Request.Cookies["payumoney"].Value }; db.AlgoExpiries.Add(algo); db.SaveChanges(); return(Json(new { data = true, status = "Success" }, JsonRequestBehavior.AllowGet)); } else { DateTime date = DateTime.ParseExact(algo.DateExpiry.Replace("-", "/"), "dd/MM/yyyy", CultureInfo.InvariantCulture); algo.DateExpiry = date < DateTime.Now ? DateTime.Now.AddMonths(1).ToString("dd-MM-yyyy") : date.AddMonths(1).ToString("dd-MM-yyyy"); algo.MaxUser = Request.Cookies["payumoney"].Value; db.SaveChanges(); return(Json(new { data = true, status = "Success" }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { data = true, status = "Failed" }, JsonRequestBehavior.AllowGet)); } } }
public JsonResult SocialLogin(UserDetail data) { if (data != null) { using (eponym_app_licenseEntities db = new eponym_app_licenseEntities()) { if (!IsUserExist(data.SocialId)) { data.CreatedDate = DateTime.Now; data.Password = Guid.NewGuid().ToString("N").ToLower() .Replace("1", "").Replace("o", "").Replace("0", "") .Substring(0, 10); data.IsEmailVerified = true; data.UserRole = "client"; db.UserDetails.Add(data); db.SaveChanges(); int newCustomer = data.Id; var user = db.UserDetails.Find(newCustomer); if (user != null) { Session["UserCredentials"] = new UserCredentials() { emailid = user.emailid, Id = user.Id, Name = user.Name, Mobile = user.Mobile, UserRole = user.UserRole, City = user.City, State = user.State, SocialId = user.SocialId, Password = user.Password }; return(Json(new { data = user, status = "Success" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { data = true, status = "Failed" }, JsonRequestBehavior.AllowGet)); } } else { var user = db.UserDetails.Where(x => x.SocialId == data.SocialId).FirstOrDefault(); if (user != null) { Session["UserCredentials"] = new UserCredentials() { emailid = user.emailid, Id = user.Id, Name = user.Name, Mobile = user.Mobile, UserRole = user.UserRole, City = user.City, State = user.State, SocialId = user.SocialId, Password = user.Password }; return(Json(new { data = user, status = "Success" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { data = true, status = "Failed" }, JsonRequestBehavior.AllowGet)); } } } } return(Json(new { data = true, status = "Success" }, JsonRequestBehavior.AllowGet)); }
public JsonResult UpdateReseller(ResellerViewModel categoryVM) { try { if (categoryVM != null) { if (!string.IsNullOrEmpty(categoryVM.emailid)) { if (IsUserExists(categoryVM.emailid, categoryVM.CustomerID)) { return(Json(new { data = false, status = "Duplicate" }, JsonRequestBehavior.AllowGet)); } else { using (eponym_app_licenseEntities db = new eponym_app_licenseEntities()) { var user = db.UserDetails.Find(categoryVM.CustomerID); user.City = categoryVM.City; user.Password = categoryVM.Password; user.State = categoryVM.State; user.emailid = categoryVM.emailid; user.Mobile = categoryVM.Mobile; user.Name = categoryVM.CustomerName; user.ResellerId = categoryVM.CustomerID; var algo = db.AlgoExpiries.Where(x => x.CustomerID == categoryVM.CustomerID).FirstOrDefault(); if (algo != null) { DateTime date = DateTime.ParseExact(categoryVM.DateExpiry.Replace("-", "/"), "dd/MM/yyyy", CultureInfo.InvariantCulture); algo.DateExpiry = date.ToString("dd-MM-yyyy"); algo.DeviceID = categoryVM.DeviceID; } var setting = db.AppSettings.Where(x => x.ResellerId == categoryVM.CustomerID).FirstOrDefault(); if (setting != null) { setting.Amount = categoryVM.ResellerAmount; } db.SaveChanges(); } } } } return(Json(new { data = true, status = "Success", error = "An Error Occurred" }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { data = false, status = "Failed", error = ex.Message.ToString() }, JsonRequestBehavior.AllowGet)); } }
/// <summary> /// /// </summary> /// <param name="user"></param> /// <returns></returns> public ActionResult AddUser(UserDetail user) { bool Status = false; string message = ""; if (user != null) { using (eponym_app_licenseEntities db = new eponym_app_licenseEntities()) { user.CreatedDate = DateTime.Now; user.UserRole = "client"; db.UserDetails.Add(user); if (1 == db.SaveChanges()) { var messagedata = new { email = user.emailid, url = System.Web.HttpContext.Current.Request.Url.Scheme + "://" + System.Web.HttpContext.Current.Request.Url.Authority, token = System.Web.HttpContext.Current.Server.UrlEncode(Security.Encrypt(user.Id.ToString())) }; MailManager mm = new MailManager(); String exMessage = mm.SendMail(user.emailid, Messages.ACCOUNT_ACTIVATION, string.Format(Messages.NEW_USERREGISTRATION_MESSAGE, messagedata.email, messagedata.url, messagedata.token)); if ("success" == exMessage) { message = "Registration successfully done. Account activation link " + " has been sent to your email id:" + user.emailid; Status = true; } else { throw new Exception(exMessage); } } } } Session["Message"] = message; Session["Status"] = Status; return(RedirectToAction("Index")); }
public ActionResult AddSevenDaysTrial(string request) { try { if (!string.IsNullOrEmpty(request)) { var converter = new ExpandoObjectConverter(); dynamic data = JsonConvert.DeserializeObject <ExpandoObject>(request, converter); UserCredentials user = (UserCredentials)(Session["UserCredentials"]); if (data != null && user != null) { using (eponym_app_licenseEntities db = new eponym_app_licenseEntities()) { var algo = db.AlgoExpiries.FirstOrDefault(x => x.CustomerID == user.Id); if (algo == null) { algo = new AlgoExpiry(); } algo.DateExpiry = DateTime.Now.AddDays(7).ToString("dd-MM-yyyy"); algo.CustomerID = user.Id; algo.AppName = "Default"; algo.MaxUser = data.MaxUsers; algo.DeviceID = data.DeviceID; db.AlgoExpiries.Add(algo); db.SaveChanges(); Session["deviceID"] = data.DeviceID; } } return(Json(new { data = data.DeviceID, status = "Success", error = Messages.BAD_DATA }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { data = false, status = "Failed", error = Messages.Somethingwentwrong }, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { return(Json(new { data = false, status = "Failed", error = ex.Message.ToString() }, JsonRequestBehavior.AllowGet)); } }
public ActionResult HandleResellerPayments(string param) { try { if (!string.IsNullOrEmpty(param)) { var paymentList = JsonConvert.DeserializeObject <List <PaymentResponse> >(param); using (eponym_app_licenseEntities db = new eponym_app_licenseEntities()) { foreach (var item in paymentList) { var algo = db.AlgoExpiries.FirstOrDefault(x => x.CustomerID == item.id); if (algo != null) { DateTime date = DateTime.ParseExact(algo.DateExpiry.Replace("-", "/"), "dd/MM/yyyy", CultureInfo.InvariantCulture); algo.DateExpiry = date < DateTime.Now ? DateTime.Now.AddMonths(1).ToString("dd-MM-yyyy") : date.AddMonths(1).ToString("dd-MM-yyyy"); algo.MaxUser = item.maxuser; } else { algo = new AlgoExpiry(); algo.DateExpiry = DateTime.Now.AddMonths(1).ToString("dd-MM-yyyy"); algo.CustomerID = item.id; algo.AppName = "Default"; algo.MaxUser = item.maxuser; db.AlgoExpiries.Add(algo); } db.SaveChanges(); } return(Json(new { data = true, status = "Success" }, JsonRequestBehavior.AllowGet)); } } } catch (Exception ex) { return(Json(new { data = true, status = "Failed" }, JsonRequestBehavior.AllowGet)); } return(Json(new { data = true, status = "Failed" }, JsonRequestBehavior.AllowGet)); }
public bool UpdateAccountActivation(int id) { UserDetail user = new UserDetail(); try { user = db.UserDetails.FirstOrDefault(x => x.Id == id); if (user == null) { throw new Exception(Messages.BAD_DATA); } else { user.IsEmailVerified = true; db.SaveChanges(); return(true); } } catch (Exception ex) { throw new Exception(ex.Message.ToString()); } }
public ActionResult MarkAsReseller(string param) { using (eponym_app_licenseEntities db = new eponym_app_licenseEntities()) { if (!string.IsNullOrEmpty(param)) { var user = db.UserDetails.Find(int.Parse(param.Split(',')[0])); if (user != null) { try { user.UserRole = "reseller"; var uid = Convert.ToInt32(param.Split(',')[0].ToString()); var setting = db.AppSettings.Where(x => x.ResellerId == uid).FirstOrDefault(); if (setting == null) { db.AppSettings.Add(new AppSetting { Amount = int.Parse(param.Split(',')[1]), ResellerId = int.Parse(param.Split(',')[0]) }); } else { setting.Amount = int.Parse(param.Split(',')[1]); } db.SaveChanges(); return(Json(new { data = true, status = "Success" }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { throw new Exception(ex.Message.ToString()); } } } } return(Json(new { data = false, status = "Failed" }, JsonRequestBehavior.AllowGet)); }
public ActionResult DeleteClient(int id) { using (eponym_app_licenseEntities db = new eponym_app_licenseEntities()) { if (id > 0) { var user = db.UserDetails.Find(id); if (user != null) { try { db.UserDetails.Remove(user); db.SaveChanges(); return(Json(new { data = true, status = "Success" }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { throw new Exception(ex.Message.ToString()); } } } } return(Json(new { data = false, status = "Failed" }, JsonRequestBehavior.AllowGet)); }
public JsonResult UpdateClient(ClientViewModel categoryVM) { try { UserCredentials user1 = (UserCredentials)(Session["UserCredentials"]); if (categoryVM != null) { if (!string.IsNullOrEmpty(categoryVM.emailid)) { if (IsUserExists(categoryVM.emailid, categoryVM.CustomerID)) { return(Json(new { data = false, status = "Duplicate" }, JsonRequestBehavior.AllowGet)); } else { using (eponym_app_licenseEntities db = new eponym_app_licenseEntities()) { var user = db.UserDetails.Find(categoryVM.CustomerID); if (user == null) { user = new UserDetail(); user.IsEmailVerified = true; user.ResellerId = user1.Id; user.CreatedDate = DateTime.Now; user.UserRole = "resellerclient"; } user.City = categoryVM.City; user.Password = categoryVM.Password; user.State = categoryVM.State; user.emailid = categoryVM.emailid; user.Mobile = categoryVM.Mobile; user.Name = categoryVM.CustomerName; if (user.Id == 0) { db.UserDetails.Add(user); db.SaveChanges(); } var userId = categoryVM.CustomerID == 0 ? user.Id : categoryVM.CustomerID; var algo = db.AlgoExpiries.Where(x => x.CustomerID == userId).FirstOrDefault(); if (algo == null) { algo = new AlgoExpiry(); } if (algo != null) { if (categoryVM.DateExpiry.Contains("-")) { categoryVM.DateExpiry = categoryVM.DateExpiry.Replace("-", "/"); } DateTime date = DateTime.ParseExact(categoryVM.DateExpiry, "dd/MM/yyyy", CultureInfo.InvariantCulture); DateTime?oldDate = null; if (!string.IsNullOrEmpty(algo.DateExpiry)) { oldDate = DateTime.ParseExact(algo.DateExpiry, "dd-mm-yyyy", CultureInfo.InvariantCulture).Date; if (user1.UserRole == "reseller" && date.Date.Date < oldDate.Value.Date) { date = DateTime.ParseExact(algo.DateExpiry, "dd-MM-yyyy", CultureInfo.InvariantCulture); } } algo.DateExpiry = date.ToString("dd-MM-yyyy"); algo.DeviceID = categoryVM.DeviceID; algo.MaxUser = categoryVM.MaxUser; algo.AppName = categoryVM.AppName; algo.CustomerID = userId; } if (algo.Id == 0) { db.AlgoExpiries.Add(algo); } db.SaveChanges(); } } } } return(Json(new { data = true, status = "Success", error = "An Error Occurred" }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { data = false, status = "Failed", error = ex.Message.ToString() }, JsonRequestBehavior.AllowGet)); } }
public ActionResult ResellerPayU(FormCollection form) { try { string[] merc_hash_vars_seq; string merc_hash_string = string.Empty; string merc_hash = string.Empty; string order_id = string.Empty; string hash_seq = "key|txnid|amount|productinfo|firstname|email|udf1|udf2|udf3|udf4|udf5|udf6|udf7|udf8|udf9|udf10"; if (form["status"].ToString() == "success") { merc_hash_vars_seq = hash_seq.Split('|'); Array.Reverse(merc_hash_vars_seq); merc_hash_string = ConfigurationManager.AppSettings["SALT"] + "|" + form["status"].ToString(); foreach (string merc_hash_var in merc_hash_vars_seq) { merc_hash_string += "|"; merc_hash_string = merc_hash_string + (form[merc_hash_var] != null ? form[merc_hash_var] : ""); } merc_hash = new Common().Generatehash512(merc_hash_string).ToLower(); if (merc_hash != form["hash"]) { return(RedirectToAction("ResellerFail", "Home")); } else { order_id = Request.Form["txnid"]; var nameWithID = Request.Form["firstname"]; var jsonUser = Request.Cookies["payumoney"].Value; using (eponym_app_licenseEntities db = new eponym_app_licenseEntities()) { var paymentList = JsonConvert.DeserializeObject <List <PaymentResponse> >(jsonUser); foreach (var item in paymentList) { var algo1 = db.AlgoExpiries.FirstOrDefault(x => x.CustomerID == item.id); if (algo1 != null) { DateTime date = DateTime.ParseExact(algo1.DateExpiry.Replace("-", "/"), "dd/MM/yyyy", CultureInfo.InvariantCulture); algo1.DateExpiry = date < DateTime.Now ? DateTime.Now.AddMonths(1).ToString("dd-MM-yyyy") : date.AddMonths(1).ToString("dd-MM-yyyy"); algo1.MaxUser = item.maxuser; db.SaveChanges(); } } } ClearCookies(); return(RedirectToAction("ResellerSuccess", "Home")); //Hash value did not matched } } else { ClearCookies(); return(RedirectToAction("ResellerFail", "Home")); } } catch (Exception ex) { ClearCookies(); return(RedirectToAction("ResellerFail", "Home")); } }
public ActionResult ReturnReseller(FormCollection form) { try { string[] merc_hash_vars_seq; string merc_hash_string = string.Empty; string merc_hash = string.Empty; string order_id = string.Empty; string hash_seq = "key|txnid|amount|productinfo|firstname|email|udf1|udf2|udf3|udf4|udf5|udf6|udf7|udf8|udf9|udf10"; if (form["status"].ToString() == "success") { merc_hash_vars_seq = hash_seq.Split('|'); Array.Reverse(merc_hash_vars_seq); merc_hash_string = ConfigurationManager.AppSettings["SALT"] + "|" + form["status"].ToString(); foreach (string merc_hash_var in merc_hash_vars_seq) { merc_hash_string += "|"; merc_hash_string = merc_hash_string + (form[merc_hash_var] != null ? form[merc_hash_var] : ""); } merc_hash = new Common().Generatehash512(merc_hash_string).ToLower(); if (merc_hash != form["hash"]) { return(View("Fail")); } else { order_id = Request.Form["txnid"]; using (eponym_app_licenseEntities db = new eponym_app_licenseEntities()) { var nameWithID = Request.Form["firstname"]; var userId = Convert.ToInt32(nameWithID.Split(',')[1]); var algo = db.AlgoExpiries.FirstOrDefault(x => x.CustomerID == userId); if (algo == null) { algo = new AlgoExpiry() { CustomerID = userId, DeviceID = Request.Form["productinfo"], DateExpiry = DateTime.Now.AddDays(7).ToString("dd-MM-yyyy"), AppName = "Default", MaxUser = "******" }; db.AlgoExpiries.Add(algo); db.SaveChanges(); } else { DateTime date = DateTime.ParseExact(algo.DateExpiry.Replace("-", "/"), "dd/MM/yyyy", CultureInfo.InvariantCulture); algo.DateExpiry = date < DateTime.Now ? DateTime.Now.AddMonths(1).ToString("dd-MM-yyyy") : date.AddMonths(1).ToString("dd-MM-yyyy"); db.SaveChanges(); } } return(RedirectToAction("ResellerSuccess", "Home")); //Hash value did not matched } } else { return(RedirectToAction("ResellerFail", "Home")); } } catch (Exception ex) { return(RedirectToAction("ResellerFail", "Home")); } }