public ActionResult InvitedUsers() { try { SuperAdminDAL DAL = new SuperAdminDAL(); SuperAdminViewModel viewModel = new SuperAdminViewModel(); int UserProfileId = Convert.ToInt32(Session["UserProfileId"]); viewModel.PromotionEmailList = DAL.GetInvitedUsers(UserProfileId); return(View(viewModel)); } catch (Exception ex) { throw; } }
public ActionResult SaveInvitedUsers(PromotionEmail PromotionEmail) { try { string status = ""; string LimitationMessage = ""; SuperAdminDAL DAL = new SuperAdminDAL(); SuperAdminViewModel viewModel = new SuperAdminViewModel(); int UserProfileId = Convert.ToInt32(Session["UserProfileId"]); string UserType = Convert.ToString(Session["UserType"]); string AuthToken = Guid.NewGuid().ToString(); if (UserType == "SuperAdmin") { AuthToken = AuthToken + "~10"; PromotionEmail.AllowedInvitations = 10; } else { AuthToken = AuthToken + "~0"; PromotionEmail.AllowedInvitations = 0; } PromotionEmail.AuthToken = AuthToken; PromotionEmail.InvitedBy = UserProfileId; PromotionEmail.RegistrationLink = "https://moments.fooddesignbrazil.com/Login/RegisterUser?Email=" + PromotionEmail.Email + "&AuthToken=" + AuthToken; status = DAL.SaveInvitedUsers(UserProfileId, UserType, PromotionEmail); if (status == "AlreadyExists") { LimitationMessage = "This User Is Already Invited."; } else if (status == "Success") { //sending email SendInvitationEmail(PromotionEmail.Email, PromotionEmail.RegistrationLink); //sending email end LimitationMessage = "Record Save Successfully."; } else if (status == "InvitationExceeded") { LimitationMessage = "Your Invitation Count Reached To Limit."; } else if (status == "NotPermission") { LimitationMessage = "Your have Not Permission To Invite."; } else { LimitationMessage = ""; } viewModel.PromotionEmailList = DAL.GetInvitedUsers(UserProfileId); var ManageInvitedUsers = RenderRazorViewToString(this.ControllerContext, "_ManageInvitedUsers", viewModel); string data = JsonConvert.SerializeObject(new { LimitationMessage, ManageInvitedUsers }); return(Json(data, JsonRequestBehavior.AllowGet)); // return PartialView("_ManageInvitedUsers", viewModel); } catch (Exception ex) { throw; } }