public ActionResult AssignDepRep(AssignDepRepViewModel viewmodel, int userid = 0) { if (userid == 0) { Session["noti"] = true; Session["notitype"] = "error"; Session["notititle"] = "Assign Department Representative"; Session["notimessage"] = "Please select one employee!"; return(RedirectToAction("AssignDepRep")); } string token = GetToken(); UserModel um = GetUser(); UserModel upum = new UserModel(); try { if (viewmodel != null) { upum = APIUser.AssignDepRep(token, userid, out string error); } } catch (Exception ex) { return(RedirectToAction("Index", "Error", new { error = ex.Message })); } Session["noti"] = true; Session["notitype"] = "success"; Session["notititle"] = "Assign Department Representative"; Session["notimessage"] = upum.Fullname + " is assigned as Department Representative"; return(RedirectToAction("AssignDepRep")); }
public ActionResult AssignDepRep() { string token = GetToken(); UserModel um = GetUser(); List <UserModel> newum = new List <UserModel>(); AssignDepRepViewModel viewModel = new AssignDepRepViewModel(); try { newum = APIUser.GetAssignRepUserList(token, um.Deptid, out string error); ViewBag.userlist = newum; List <UserModel> um23 = APIUser.GetUserByRoleAndDeptID(6, um.Deptid, token, out string depreperror); foreach (UserModel um1 in um23) { ViewBag.assignedrep = um1.Fullname; } if (error != "") { return(RedirectToAction("Index", "Error", new { error })); } } catch (Exception ex) { return(RedirectToAction("Index", "Error", new { error = ex.Message })); } return(View(viewModel)); }