public ActionResult Edit(decimal?id) { if (id != Convert.ToDecimal(UserHelper.GetUserId())) { TempData["message"] = ToasterMessage.Message(ToastType.warning, "Unauthorized Access"); return(RedirectToAction("Index")); } if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } User_Profile user_Profile = db.User_Profile.Find(id); if (user_Profile == null) { return(HttpNotFound()); } ViewBag.CountryID = new SelectList(db.Country_Master.OrderBy(m => m.Name), "ID", "Name", user_Profile.CountryID); ViewBag.Role_id = new SelectList(db.Role_Master, "Id", "Name", user_Profile.Role_id); ViewBag.StateID = new SelectList(db.State_Master.OrderBy(m => m.Name), "ID", "Name", user_Profile.StateID); ViewBag.StateEnrolled = new SelectList(db.State_Master.OrderBy(m => m.Name), "ID", "Name", user_Profile.StateEnrolled); return(View(user_Profile)); }
public ActionResult ForgotPassword(User_Profile user_profile) { try { using (LaxNarroEntities db = new LaxNarroEntities()) { var account = db.User_Profile.Where(a => a.EmailAddress == user_profile.EmailAddress).ToList(); //var GetUserData = (db.User_Profile.Where(a => a.EmailAddress == email).ToList()); string mailResult = ""; if (account != null) { mailResult = SendMail(account[0].EmailAddress, "~/EmailTemplate/ForgotPassword.html", account[0].FirstName, account[0].LastName, account[0].Password); } else { ViewBag.message = ToasterMessage.Message(ToastType.error, "Invalid email"); } if (mailResult == "success") { ViewBag.message = ToasterMessage.Message(ToastType.success, "Password sent, check your email"); } } } catch (Exception) { } return(View()); }
public ActionResult Create([Bind(Include = "Rate_Id,Plan_Id,StartDate,EndDate,Amount,Status")] Rate_Card rate_Card) { ViewBag.Plan_Id = new SelectList(db.Plan_Master.OrderBy(m => m.Plan), "Plan_ID", "Plan"); try { //if (ModelState.IsValid) //{ if (rate_Card.StartDate > rate_Card.EndDate) { ViewBag.message = ToasterMessage.Message(ToastType.info, "End date should be greater then start date"); return(View()); } else { var getName = db.Rate_Card.Where(u => u.Plan_Id == rate_Card.Plan_Id && u.StartDate == rate_Card.StartDate && u.EndDate == rate_Card.EndDate && u.Status == rate_Card.Status).ToList(); if (getName.Count > 0) { ViewBag.message = ToasterMessage.Message(ToastType.info, "Record already exist"); return(View()); } else { db.Rate_Card.Add(rate_Card); db.SaveChanges(); TempData["message"] = ToasterMessage.Message(ToastType.success, "Saved successfully"); return(RedirectToAction("Index")); } //} } } catch (DbEntityValidationException e) { string errorMessage = string.Empty; foreach (DbEntityValidationResult eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (DbValidationError ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); errorMessage = ve.ErrorMessage; ViewBag.message = ViewBag.message + ToasterMessage.Message(ToastType.error, errorMessage); } } return(View()); } catch (Exception) { ViewBag.message = ToasterMessage.Message(ToastType.error, "Something went wrong"); return(View()); } //return View(); }
public ActionResult GetPayments(decimal id) { decimal userID = Convert.ToDecimal(UserHelper.GetUserId()); var userTransaction = db.User_Transaction_Master.Include(u => u.User_Profile). Include(u => u.Rate_Card).Include(u => u.Plan_Master).Where(u => u.User_ID == id).ToList(); if (userTransaction[0].User_ID != userID) { TempData["message"] = ToasterMessage.Message(ToastType.warning, "Unauthorized access."); return(RedirectToAction("Index")); } var transactions = userTransaction.ToList().Select(item => new { item.Id, item.User_ID, item.User_Profile.FirstName, item.User_Profile.LastName, item.Plan_Master.Plan, item.Amount, StartDate = item.Start_Date.ToShortDateString(), EndDate = item.End_Date.ToString().Split(' ')[0], PaymentDate = item.Payment_Date.ToString().Split(' ')[0], item.Payment_Status, item.Transection_ID, item.Status, item.Invoice_No }); return(Json(new { data = transactions }, JsonRequestBehavior.AllowGet)); }
public ActionResult Cancel(string payerId, string paymentId) { try { //using (LaxNarroEntities ctx = new LaxNarroEntities()) //{ // using (DbContextTransaction transaction = ctx.Database.BeginTransaction()) // { // User_Transaction_Master dfd = ctx.User_Transaction_Master.Where(x => x.Transection_ID == paymentId).First(); // PaypalResponse pr = ctx.PaypalResponses.Where(x => x.Paypal_ReferenceId == paymentId).First(); // ctx.PaypalResponses.Remove(pr); // ctx.SaveChanges(); // ctx.User_Transaction_Master.Remove(dfd); // ctx.SaveChanges(); // transaction.Commit(); TempData["message"] = ToasterMessage.Message(ToastType.info, "Transaction cancelled by user."); // } //} } catch (Exception tt) { TempData["message"] = ToasterMessage.Message(ToastType.error, "Something went wrong."); } return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Id,StateID,ActivityID,Rule2_ID,StartDate,EndDate,Status")] StateActivity__with_Rule2 stateActivity__with_Rule2) { try { ViewBag.ActivityID = new SelectList(db.Activity_Master.OrderBy(m => m.Name), "ID", "Name", stateActivity__with_Rule2.ActivityID); ViewBag.Rule2_ID = new SelectList(db.Rule2_Master.OrderBy(m => m.Name), "Id", "Name", stateActivity__with_Rule2.Rule2_ID); ViewBag.StateID = new SelectList(db.State_Master.OrderBy(m => m.Name), "ID", "Name", stateActivity__with_Rule2.StateID); if (stateActivity__with_Rule2.StartDate > stateActivity__with_Rule2.EndDate) { ViewBag.message = ToasterMessage.Message(ToastType.info, "End date should be greater then start date"); return(View()); } else { List <StateActivity__with_Rule2> getName = db.StateActivity__with_Rule2.Where(u => u.StateID == stateActivity__with_Rule2.StateID && u.Rule2_ID == stateActivity__with_Rule2.Rule2_ID && u.StartDate == stateActivity__with_Rule2.StartDate && u.EndDate == stateActivity__with_Rule2.EndDate && u.Status == stateActivity__with_Rule2.Status && u.ActivityID == stateActivity__with_Rule2.ActivityID && u.Id != stateActivity__with_Rule2.Id).ToList(); if (getName.Count > 0) { ViewBag.message = ToasterMessage.Message(ToastType.info, "Record already exist"); return(View()); } else { db.Entry(stateActivity__with_Rule2).State = EntityState.Modified; db.SaveChanges(); TempData["message"] = ToasterMessage.Message(ToastType.success, "Updated Successfully"); return(RedirectToAction("Index")); } } } catch (DbEntityValidationException e) { string errorMessage = string.Empty; foreach (DbEntityValidationResult eve in e.EntityValidationErrors) { System.Diagnostics.Debug.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (DbValidationError ve in eve.ValidationErrors) { System.Diagnostics.Debug.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); errorMessage = ve.ErrorMessage; ViewBag.message = ViewBag.message + ToasterMessage.Message(ToastType.error, errorMessage); } } return(View()); } catch (Exception) { ViewBag.message = ToasterMessage.Message(ToastType.error, "Something went wrong"); } return(View()); }
public ActionResult Create([Bind(Include = "ID,Name,Activity_ID,ShortName,StateID")] Sub_Activity_Master sub_Activity_Master) { try { ViewBag.Activity_ID = new SelectList(db.Activity_Master.OrderBy(m => m.Name), "ID", "Name", sub_Activity_Master.Activity_ID); ViewBag.StateID = new SelectList(db.State_Master.OrderBy(s => s.Name), "ID", "Name", sub_Activity_Master.StateID); //if (ModelState.IsValid) //{ var getName = db.Sub_Activity_Master.Where(u => u.Name == sub_Activity_Master.Name && u.Activity_ID == sub_Activity_Master.Activity_ID && u.StateID == sub_Activity_Master.StateID).ToList(); if (getName.Count > 0) { ViewBag.message = ToasterMessage.Message(ToastType.info, "Record already exist"); return(View()); } else { db.Sub_Activity_Master.Add(sub_Activity_Master); db.SaveChanges(); TempData["message"] = ToasterMessage.Message(ToastType.success, "Saved successfully"); return(RedirectToAction("Index")); } //} } catch (DbEntityValidationException e) { string errorMessage = string.Empty; foreach (DbEntityValidationResult eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (DbValidationError ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); errorMessage = ve.ErrorMessage; ViewBag.message = ViewBag.message + ToasterMessage.Message(ToastType.error, errorMessage); } } return(View()); } catch (Exception) { ViewBag.message = ToasterMessage.Message(ToastType.error, "Something went wrong"); } return(View()); }
public ActionResult Edit([Bind(Include = "Plan_ID,Plan")] Plan_Master plan_Master) { try { //if (ModelState.IsValid) //{ var getName = db.Plan_Master.Where(u => u.Plan == plan_Master.Plan && u.Plan_ID != plan_Master.Plan_ID).ToList(); if (getName.Count > 0) { ViewBag.message = ToasterMessage.Message(ToastType.info, "Record already exist"); return(View()); } else { db.Entry(plan_Master).State = EntityState.Modified; db.SaveChanges(); TempData["message"] = ToasterMessage.Message(ToastType.success, "Updated Successfully"); return(RedirectToAction("Index")); } //} } catch (DbEntityValidationException e) { string errorMessage = string.Empty; foreach (DbEntityValidationResult eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (DbValidationError ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); errorMessage = ve.ErrorMessage; ViewBag.message = ViewBag.message + ToasterMessage.Message(ToastType.error, errorMessage); } } return(View()); } catch (Exception) { ViewBag.message = ToasterMessage.Message(ToastType.error, "Something went wrong"); } return(View()); }
public ActionResult Create([Bind(Include = "Id,Name,Unit,Hours")] Rule2_Master rule2_Master) { try { //if (ModelState.IsValid) //{ System.Collections.Generic.List <Rule2_Master> getName = db.Rule2_Master.Where(u => u.Name == rule2_Master.Name).ToList(); if (getName.Count > 0) { ViewBag.message = ToasterMessage.Message(ToastType.info, "Record already exist"); return(View()); } else { db.Rule2_Master.Add(rule2_Master); db.SaveChanges(); TempData["message"] = ToasterMessage.Message(ToastType.success, "Saved successfully"); return(RedirectToAction("Index")); } //} } catch (DbEntityValidationException e) { string errorMessage = string.Empty; foreach (DbEntityValidationResult eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (DbValidationError ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); errorMessage = ve.ErrorMessage; ViewBag.message = ViewBag.message + ToasterMessage.Message(ToastType.error, errorMessage); } } return(View()); } catch (Exception) { ViewBag.message = ToasterMessage.Message(ToastType.error, "Something went wrong"); } return(View()); }
public ActionResult PaymentDetails(decimal id) { decimal userID = Convert.ToDecimal(UserHelper.GetUserId()); User_Transaction_Master userTransaction = db.User_Transaction_Master.Include(u => u.User_Profile). Include(u => u.Rate_Card).Include(u => u.Plan_Master).Where(u => u.Id == id).SingleOrDefault(); if (userTransaction.User_ID != userID) { TempData["message"] = ToasterMessage.Message(ToastType.warning, "Unauthorized access."); return(RedirectToAction("Index")); } if (userTransaction == null) { return(HttpNotFound()); } return(View(userTransaction)); }
public ActionResult Details(decimal?id) { User_Profile user_Profile = null; if (UserHelper.GetUserRole() == "Admin") { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } user_Profile = db.User_Profile.Find(id); if (user_Profile == null) { return(HttpNotFound()); } } else { if (id != Convert.ToDecimal(UserHelper.GetUserId())) { TempData["message"] = ToasterMessage.Message(ToastType.warning, "Unauthorized Access"); return(RedirectToAction("Index")); } if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } user_Profile = db.User_Profile.Find(id); if (user_Profile == null) { return(HttpNotFound()); } } return(View(user_Profile)); }
public ActionResult DeleteConfirmed(decimal?id) { try { Category_Master category_Master = db.Category_Master.Find(id); db.Category_Master.Remove(category_Master); db.SaveChanges(); TempData["message"] = ToasterMessage.Message(ToastType.success, "Deleted successfully"); return(RedirectToAction("Index")); } catch (DbEntityValidationException e) { string errorMessage = string.Empty; foreach (DbEntityValidationResult eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (DbValidationError ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); errorMessage = ve.ErrorMessage; ViewBag.message = ViewBag.message + ToasterMessage.Message(ToastType.error, errorMessage); } } return(View()); } catch (Exception) { ViewBag.message = ToasterMessage.Message(ToastType.error, "Something went wrong"); } return(View()); }
public ActionResult Signup(User_Profile userProfileCreate) { try { var getName = db.User_Profile.Where(u => u.EmailAddress == userProfileCreate.EmailAddress).ToList(); if (getName.Count > 0) { ViewBag.message = ToasterMessage.Message(ToastType.info, "User already exist"); } else { using (var transaction = db.Database.BeginTransaction()) { userProfileCreate.Date = DateTime.Today; userProfileCreate.UserName = userProfileCreate.EmailAddress; userProfileCreate.Role_id = 1; userProfileCreate.Current_Financial_year = GetFinancialYear(); userProfileCreate.AccountConfirmed = "No"; Guid activationCode = Guid.NewGuid(); userProfileCreate.ActivationCode = activationCode; string activationLink = Request.Url.Scheme + "://" + Request.Url.Authority + "/User/ConfirmAccount/" + activationCode; db.User_Profile.Add(userProfileCreate); db.SaveChanges(); decimal id = userProfileCreate.ID; var user_Transaction_Master = new User_Transaction_Master(); var plan_id = db.Plan_Master.FirstOrDefault(x => x.Plan == "Demo"); decimal planID = Convert.ToDecimal(plan_id.Plan_ID); var rate_id = db.Rate_Card.FirstOrDefault(x => x.Plan_Id == planID); decimal rateID = Convert.ToDecimal(rate_id.Rate_Id); user_Transaction_Master.Rate_ID = rateID; //******************** user_Transaction_Master.User_ID = id; user_Transaction_Master.PlanID = planID; //******************** user_Transaction_Master.Amount = 0; user_Transaction_Master.Start_Date = DateTime.Today; user_Transaction_Master.End_Date = DateTime.Today.AddMonths(3); user_Transaction_Master.Payment_Status = "N/A"; user_Transaction_Master.Transection_ID = null; user_Transaction_Master.Status = "Active"; user_Transaction_Master.Payment_Date = null; user_Transaction_Master.Invoice_No = null; user_Transaction_Master.Payment_Method = "N/A"; db.User_Transaction_Master.Add(user_Transaction_Master); db.SaveChanges(); var mailLog = new MailLog { UserID = id, ReminderOne = DateTime.Today.AddDays(2), ReminderTwo = DateTime.Today.AddDays(7), ReminderThree = DateTime.Today.AddDays(14), ReminderFour = DateTime.Today.AddDays(30), ReminderFive = DateTime.Today.AddDays(60), ReminderSix = DateTime.Today.AddDays(90) }; db.MailLogs.Add(mailLog); db.SaveChanges(); transaction.Commit(); SendMail(userProfileCreate.FirstName, userProfileCreate.LastName, userProfileCreate.EmailAddress, activationLink, "~/EmailTemplate/SignupConfirmation.html", "Lex Narro - Verify email to activate account"); //SendMail("sanjay", "kumar", "*****@*****.**", // "", "~/EmailTemplate/SignupConfirmation.html"); TempData["message"] = ToasterMessage.MessageCenter(ToastType.success, "Registration successful. Check your email for account activation."); return(RedirectToAction("Login", "Account")); } } //} } catch (Exception ex) { TempData["message"] = ToasterMessage.Message(ToastType.info, "something went wrong. Please contact us from home page."); } ViewBag.CountryID = new SelectList(db.Country_Master.OrderBy(m => m.Name), "ID", "Name"); ViewBag.Role_id = new SelectList(db.Role_Master, "Id", "Name"); ViewBag.StateID = new SelectList(db.State_Master.OrderBy(m => m.Name), "ID", "Name"); ViewBag.StateEnrolled = new SelectList(db.State_Master.OrderBy(m => m.Name), "ID", "Name"); return(View()); }
//[ValidateAntiForgeryToken] public ActionResult PayNow(decimal planId) { try { decimal userId = Convert.ToDecimal(UserHelper.GetUserId()); IEnumerable <Rate_Card> plan_master = from s in db.Rate_Card join b in db.Plan_Master on s.Plan_Id equals b.Plan_ID where b.Plan != "Demo" select s; ViewBag.PM = plan_master; string amount = string.Empty; string planName = plan_master.Where(x => x.Plan_Id == planId).Select(x => x.Plan_Master.Plan).First(); using (LaxNarroEntities ctx = new LaxNarroEntities()) { using (var transaction = ctx.Database.BeginTransaction()) { var userTransaction = ctx.User_Transaction_Master.FirstOrDefault(x => x.User_ID == userId); string desc = string.Empty; if (planName == "Yearly") { desc = "Lex Narro Yearly Plan Subscription."; //amount = "13.99"; amount = plan_master.Select(x => x.Amount).FirstOrDefault().ToString(); } else { desc = "Lex Narro 2 Yearly Plan Subscription."; //amount = "24.99"; amount = plan_master.Select(x => x.Amount).FirstOrDefault().ToString(); } var apiContext = GetAPIContext(); var payment = new Payment { //For Sandbox testing //experience_profile_id = "XP-3FDL-P42J-GUEG-25ZK", //For live paypal account experience_profile_id = "XP-R4X7-FQ49-PL4T-HLNR", intent = "sale", payer = new Payer { payment_method = "paypal" }, transactions = new List <Transaction> { new Transaction { description = desc, amount = new Amount { currency = "AUD", total = amount, }, item_list = new ItemList { items = new List <Item>() { new Item() { description = "Lex Narro " + planName + " plan subscription.", currency = "AUD", quantity = "1", price = amount } } } } }, redirect_urls = new RedirectUrls { return_url = Url.Action("Success", "Subscription", new { planId = planId }, Request.Url.Scheme), cancel_url = Url.Action("Cancel", "Subscription", new { planId = planId }, Request.Url.Scheme) } }; Payment createdPayment = payment.Create(apiContext); var approvalUrl = createdPayment.links .FirstOrDefault(x => x.rel.Equals("approval_url", StringComparison.OrdinalIgnoreCase)); return(Redirect(approvalUrl.href)); } } } catch (DbEntityValidationException e) { string errorMessage = string.Empty; foreach (DbEntityValidationResult eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (DbValidationError ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); errorMessage = ve.ErrorMessage; TempData["message"] = ViewBag.message + ToasterMessage.Message(ToastType.error, errorMessage); } } return(RedirectToAction("Index")); } catch (Exception rr) { TempData["message"] = ToasterMessage.Message(ToastType.error, "Something went wrong " + rr.ToString()); } return(RedirectToAction("Index")); }
public ActionResult Edit(UserProfileEditViewModel userProfileEdit) { if (userProfileEdit.ID != Convert.ToDecimal(UserHelper.GetUserId())) { TempData["message"] = ToasterMessage.Message(ToastType.warning, "Unauthorized Access"); return(RedirectToAction("Index")); } User_Profile user_Profile = db.User_Profile.Find(userProfileEdit.ID); try { ViewBag.CountryID = new SelectList(db.Country_Master.OrderBy(m => m.Name), "ID", "Name", user_Profile.CountryID); ViewBag.Role_id = new SelectList(db.Role_Master, "Id", "Name", user_Profile.Role_id); ViewBag.StateID = new SelectList(db.State_Master.OrderBy(m => m.Name), "ID", "Name", user_Profile.StateID); ViewBag.StateEnrolled = new SelectList(db.State_Master.OrderBy(m => m.Name), "ID", "Name", user_Profile.StateEnrolled); user_Profile.UserName = userProfileEdit.EmailAddress; user_Profile.FirstName = userProfileEdit.FirstName; user_Profile.LastName = userProfileEdit.LastName; user_Profile.OtherName = userProfileEdit.OtherName; user_Profile.StateID = userProfileEdit.StateID; user_Profile.StreetName = userProfileEdit.StreetName; user_Profile.StreetNumber = userProfileEdit.StreetNumber; user_Profile.PostCode = userProfileEdit.PostCode; user_Profile.Suburb = userProfileEdit.Suburb; user_Profile.LawSocietyNumber = userProfileEdit.LawSocietyNumber; user_Profile.PhoneNumber = userProfileEdit.PhoneNumber; user_Profile.Date = userProfileEdit.Date; user_Profile.Address = userProfileEdit.Address; db.Entry(user_Profile).State = EntityState.Modified; db.SaveChanges(); TempData["message"] = ToasterMessage.Message(ToastType.success, "Updated Successfully"); } catch (DbEntityValidationException e) { string errorMessage = string.Empty; foreach (DbEntityValidationResult eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (DbValidationError ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); errorMessage = ve.ErrorMessage; ViewBag.message = ViewBag.message + ToasterMessage.Message(ToastType.error, errorMessage); } } return(View()); } return(RedirectToAction("Index")); }
public ActionResult GetTraining(decimal id, string finYear) { decimal userId = Convert.ToDecimal(UserHelper.GetUserId()); decimal enrolledStateId = Convert.ToDecimal(UserHelper.GetUserStateEnrolledId()); if (id != userId) { TempData["message"] = ToasterMessage.Message(ToastType.warning, "Unauthorized access."); return(RedirectToAction("Index")); } //decimal? totalUnit = 0; List <MyCategory> totalCategories = (from s in db.State_Category_With_Rule4_Mapping join c in db.Category_Master on s.CategoryID equals c.ID where s.StateID == enrolledStateId && s.Status == "Active" select new MyCategory { CategoryID = s.CategoryID, Category_Name = c.Name, ShortName = c.ShortName }).ToList(); List <ExistingCategory> swe = new List <ExistingCategory>(); string isAllCategoriesCompleted = string.Empty; foreach (MyCategory d in totalCategories) { decimal?existedCompletedCategories = db.User_Training_Status .Include(x => x.Category_Master).Include(x => x.User_Training_Transaction) .Where(x => x.Category_Id == d.CategoryID && x.Financial_Year == finYear && x.User_Id == userId).Select(x => x.Units_Done).Sum(); if (existedCompletedCategories == null) { isAllCategoriesCompleted = "false"; break; } } decimal?carryOverUnits = db.State_Rule3_Marriage.Include(x => x.Rule3_ID) .Where(x => x.StateID == enrolledStateId).Select(x => x.Rule3_Master.CarryOverUnits).First(); if (carryOverUnits == 0) { return(Json(new { data = "This state does not allow carry over." }, JsonRequestBehavior.AllowGet)); } string nextFinYear = GetNewFinancialYear(finYear); decimal?carriedOverUnits = db.User_Training_Status.Where(x => x.Financial_Year == nextFinYear && x.User_Id == userId && x.Received_By_Forwarding == "Yes").Select(x => x.Units_Done).Sum(); if (isAllCategoriesCompleted != "false") { if (carriedOverUnits >= carryOverUnits) { return(Json(new { data = "All allowed records has been carried over" }, JsonRequestBehavior.AllowGet)); } else { List <User_Training_Status> userTraining = db.User_Training_Status .Include(x => x.User_Training_Transaction) .Where(x => x.User_Training_Transaction.Forwardable == "Yes" && x.Units_Done != 0 && x.Financial_Year == finYear && //x.User_Training_Transaction.Has_been_Forwarded == null && x.User_Id == userId) .OrderByDescending(x => x.User_Training_Transaction.Date).ToList(); //var userTransactionData = db.User_Training_Status.Where(u => u.User_Id == id && u.Financial_Year == finYear).ToList(); int totalUnits = 0; if (userTraining.Count < 1) { return(Json(new { data = "No records for carry over found." }, JsonRequestBehavior.AllowGet)); } foreach (User_Training_Status row in userTraining) { totalUnits += (int)Math.Floor(Convert.ToDecimal(row.Units_Done)); } //ViewBag.TotalUnits = totalUnits; var training = userTraining.Select(S => new { S.Id, S.User_Id, S.Training_Transaction_ID, Date = S.User_Training_Transaction.Date.ToString().Split(' ')[0], S.User_Profile.FirstName, S.User_Profile.LastName, Country = S.User_Profile.Country_Master.Name, StateEnrolled = S.User_Profile.State_Master1.Name, Category = S.Category_Master.Name, Activity = S.Activity_Master.Name, SubActivity = (S.SubActivity_Id == null) ? "" : S.Sub_Activity_Master.Name, S.User_Training_Transaction.Hours, S.User_Training_Transaction.Provider, S.Financial_Year, S.Units_Done, S.User_Profile.EmailAddress, TotalUnits = totalUnits, rowCount = userTraining.Count }); return(Json(new { data = training }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { data = "All categories are not completed." }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Edit([Bind(Include = "Id,StateID,Total_Units,Start_Date,End_Date")] Total_Unit_Master total_Unit_Master) { try { //if (ModelState.IsValid) //{ ViewBag.StateID = new SelectList(db.State_Master.OrderBy(m => m.Name), "ID", "Name", total_Unit_Master.StateID); if (total_Unit_Master.Start_Date > total_Unit_Master.End_Date) { ViewBag.message = ToasterMessage.Message(ToastType.info, "End date should be greater then start date"); return(View()); } else { List <Total_Unit_Master> getName = db.Total_Unit_Master.Where(u => u.StateID == total_Unit_Master.StateID && u.Total_Units == total_Unit_Master.Total_Units && u.Start_Date == total_Unit_Master.Start_Date && u.End_Date == total_Unit_Master.End_Date && u.Id != total_Unit_Master.Id).ToList(); if (getName.Count > 0) { ViewBag.message = ToasterMessage.Message(ToastType.info, "Record already exist"); return(View()); } else { db.Entry(total_Unit_Master).State = EntityState.Modified; db.SaveChanges(); TempData["message"] = ToasterMessage.Message(ToastType.success, "Updated Successfully"); return(RedirectToAction("Index")); } } //} } catch (DbEntityValidationException e) { string errorMessage = string.Empty; foreach (DbEntityValidationResult eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (DbValidationError ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); errorMessage = ve.ErrorMessage; ViewBag.message = ViewBag.message + ToasterMessage.Message(ToastType.error, errorMessage); } } return(View()); } catch (Exception) { ViewBag.message = ToasterMessage.Message(ToastType.error, "Something went wrong"); } return(View()); }
public ActionResult Create([Bind(Include = "ID,StateID,Rule3_ID,StartDate,EndDate,Status")] State_Rule3_Marriage state_Rule3_Marriage) { try { ViewBag.Rule3_ID = new SelectList(db.Rule3_Master, "ID", "CarryOverUnits", state_Rule3_Marriage.Rule3_ID); ViewBag.StateID = new SelectList(db.State_Master.OrderBy(m => m.Name), "ID", "Name", state_Rule3_Marriage.StateID); //if (ModelState.IsValid) //{ if (state_Rule3_Marriage.StartDate > state_Rule3_Marriage.EndDate) { ViewBag.message = ToasterMessage.Message(ToastType.info, "End date should be greater then start date"); return(View()); } else { List <State_Rule3_Marriage> getName = db.State_Rule3_Marriage.Where(u => u.StateID == state_Rule3_Marriage.StateID && u.Rule3_ID == state_Rule3_Marriage.Rule3_ID && u.StartDate == state_Rule3_Marriage.StartDate && u.EndDate == state_Rule3_Marriage.EndDate && u.Status == state_Rule3_Marriage.Status).ToList(); if (getName.Count > 0) { ViewBag.message = ToasterMessage.Message(ToastType.info, "Record already exist"); return(View()); } else { db.State_Rule3_Marriage.Add(state_Rule3_Marriage); db.SaveChanges(); TempData["message"] = ToasterMessage.Message(ToastType.success, "Saved successfully"); return(RedirectToAction("Index")); } } //} } catch (DbEntityValidationException e) { string errorMessage = string.Empty; foreach (DbEntityValidationResult eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (DbValidationError ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); errorMessage = ve.ErrorMessage; ViewBag.message = ViewBag.message + ToasterMessage.Message(ToastType.error, errorMessage); } } } catch (Exception) { ViewBag.message = ToasterMessage.Message(ToastType.error, "Something went wrong"); } return(View()); }
public ActionResult Success(decimal planId, string payerId, string paymentId) { try { decimal userId = Convert.ToDecimal(UserHelper.GetUserId()); //-----For sending Invoice mail------ decimal recordId = 0; using (LaxNarroEntities ctx = new LaxNarroEntities()) { using (var transaction = ctx.Database.BeginTransaction()) { int?maxInvoice = ctx.User_Transaction_Master.Max(u => u.Invoice_No); Rate_Card rate_card = ctx.Rate_Card.Include(x => x.Plan_Master) .Where(m => m.Plan_Id == planId && m.Status == "Active").FirstOrDefault(); User_Transaction_Master userTransaction = new User_Transaction_Master(); IEnumerable <User_Transaction_Master> userAllTransaction = ctx.User_Transaction_Master .Where(x => x.User_ID == userId); // Set the payer for the payment var paymentExecution = new PaymentExecution() { payer_id = payerId }; // Identify the payment to execute var payment = new Payment() { id = paymentId }; var apiContext = GetAPIContext(); // Execute the Payment var executedPayment = payment.Execute(apiContext, paymentExecution); int?max = userAllTransaction.Max(u => (int?)u.Invoice_No); User_Transaction_Master maxedInvoicedTransaction = userAllTransaction .FirstOrDefault(x => x.User_ID == userId && x.Invoice_No == max); int?maxedInvoiceNo = ctx.User_Transaction_Master.Max(u => (int?)u.Invoice_No); if (executedPayment.state == "approved") { //---------For new payment record (second time payment and so on)------- if (maxedInvoicedTransaction.Payment_Status != "N/A") { userTransaction.Amount = Convert.ToDecimal(rate_card.Amount); DateTime?endDate = maxedInvoicedTransaction.End_Date; string strEndDate = string.Empty; if (endDate != null) { strEndDate = endDate.ToString(); } userTransaction.Start_Date = Convert.ToDateTime(strEndDate); if (rate_card.Plan_Master.Plan == "Yearly") { userTransaction.End_Date = userTransaction.Start_Date.AddYears(1); } else { userTransaction.End_Date = userTransaction.Start_Date.AddYears(2); } if (maxInvoice == null) { userTransaction.Invoice_No = 1; } else { userTransaction.Invoice_No = maxInvoice + 1; } userTransaction.Payment_Date = DateTime.Today; userTransaction.Payment_Method = "Online"; userTransaction.Payment_Status = "Paid"; userTransaction.Paypal_PayerId = payerId; userTransaction.PlanID = rate_card.Plan_Id; userTransaction.Rate_ID = rate_card.Rate_Id; userTransaction.Status = "Active"; userTransaction.Transaction_Status = executedPayment.state; userTransaction.Transection_ID = executedPayment.id; userTransaction.User_ID = userId; ctx.User_Transaction_Master.Add(userTransaction); ctx.SaveChanges(); recordId = userTransaction.Id; } //---------For updating the demo record (First time payment)------- else { maxedInvoicedTransaction.Amount = Convert.ToDecimal(rate_card.Amount); if (rate_card.Plan_Master.Plan == "Yearly") { maxedInvoicedTransaction.End_Date = DateTime.Today.AddYears(1); } else { maxedInvoicedTransaction.End_Date = DateTime.Today.AddYears(2); } if (maxInvoice == null) { maxedInvoicedTransaction.Invoice_No = 1; } else { maxedInvoicedTransaction.Invoice_No = maxInvoice + 1; } maxedInvoicedTransaction.Payment_Date = DateTime.Today; maxedInvoicedTransaction.Payment_Method = "Online"; maxedInvoicedTransaction.Payment_Status = "Paid"; maxedInvoicedTransaction.Paypal_PayerId = payerId; maxedInvoicedTransaction.PlanID = rate_card.Plan_Id; maxedInvoicedTransaction.Rate_ID = rate_card.Rate_Id; //DateTime? endDate = maxedInvoicedTransaction.End_Date; //string strEndDate = string.Empty; //if (endDate != null) // strEndDate = endDate.ToString(); maxedInvoicedTransaction.Start_Date = DateTime.Today; maxedInvoicedTransaction.Status = "Active"; maxedInvoicedTransaction.Transaction_Status = executedPayment.state; maxedInvoicedTransaction.Transection_ID = executedPayment.id; maxedInvoicedTransaction.User_ID = userId; ctx.Entry(maxedInvoicedTransaction).State = EntityState.Modified; ctx.SaveChanges(); recordId = maxedInvoicedTransaction.Id; } PaypalResponse paypalResponse = new PaypalResponse { user_id = userId, Paypal_ReferenceId = executedPayment.id, intent = executedPayment.intent, payer = Convert.ToString(executedPayment.payer), payee = Convert.ToString(executedPayment.payee), note_to_payer = executedPayment.note_to_payer, update_time = executedPayment.update_time, create_time = executedPayment.create_time, response_state = executedPayment.state, failure_reason = executedPayment.failure_reason }; ctx.PaypalResponses.Add(paypalResponse); ctx.SaveChanges(); transaction.Commit(); MailLog user = ctx.MailLogs.FirstOrDefault(x => x.UserID == userId); user.LastReminderStatus = "Deactive"; ctx.SaveChanges(); } Thread thread = new Thread(() => SendInvoice(recordId)); thread.Start(); User_Profile userMail = ctx.User_Profile.Where(p => p.ID == userId).FirstOrDefault(); Thread thread2 = new Thread(() => SendMail(userMail.FirstName, userMail.LastName, userMail.EmailAddress, "", "Lexnarro - Subscription Successful", "~/EmailTemplate/SubscriptionMail.html")); thread2.Start(); //SendMail(userMail.FirstName, userMail.LastName, userMail.EmailAddress, "", // "Lexnarro - Subscription Successful", "~/EmailTemplate/SubscriptionMail.html"); TempData["message"] = ToasterMessage.Message(ToastType.success, "Subscription successful. Thank you."); } } } catch (DbEntityValidationException e) { string errorMessage = string.Empty; foreach (DbEntityValidationResult eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (DbValidationError ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); errorMessage = ve.ErrorMessage; TempData["message"] = ViewBag.message + ToasterMessage.Message(ToastType.error, errorMessage); } } } catch (Exception r) { TempData["message"] = ToasterMessage.Message(ToastType.error, "Something went wrong"); } return(RedirectToAction("Index")); }