예제 #1
0
        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"));
        }