public ActionResult AssignPollCreator(int pollid, String pollname) { if (Session["uid"] == null || Session["uid"].ToString().Equals("")) { return RedirectToAction("Index", "Home"); } if ((int)Session["user_type"] < User_Type.POLL_ADMINISTRATOR) { return RedirectToAction("Invalid", "Home"); } Assign_PollMasters pollMasters = new Assign_PollMasters(); pollMasters.assigned = new userModel().displayAssignedUsers(pollid, User_Type.POLL_CREATOR); pollMasters.unassigned = new userModel().displayUnassignedUsers(pollid, User_Type.POLL_CREATOR); ViewData["pollid"] = pollid; ViewData["pollname"] = pollname; return View(pollMasters); }
public ActionResult AssignPollCreator(int pollid, int[] selectedObjects, String pollname) { if (Session["uid"] == null || Session["uid"].ToString().Equals("")) { return RedirectToAction("Index", "Home"); } if ((int)Session["user_type"] < User_Type.POLL_CREATOR) { return RedirectToAction("Invalid", "Home"); } String errorString = ""; new pollModel().assignPoll(pollid, selectedObjects); Assign_PollMasters pollMasters = new Assign_PollMasters(); pollMasters.assigned = new userModel().displayAssignedUsers(pollid, User_Type.POLL_CREATOR); pollMasters.unassigned = new userModel().displayUnassignedUsers(pollid, User_Type.POLL_CREATOR); foreach (int id in selectedObjects) { userModel u = new userModel(); u = u.getUser(id); EmailController mail = new EmailController(pollname, u.username); string mailSuccess = mail.send1(); if (!mailSuccess.Equals("Email sent successfully")) { errorString += u.username + "\n"; //throw new Exception(mailSuccess); } } if(errorString.Length != 0) ViewData["emailError"] = "Could not send email to following Users: \n" + errorString; ViewData["pollid"] = pollid; ViewData["pollname"] = pollname; return View(pollMasters); }