Exemple #1
0
        public ActionResult SearchPreviousDelegation(EditDelegationViewModel viewmodel, int id)
        {
            string          token = GetToken();
            UserModel       um    = GetUser();
            DelegationModel um1   = new DelegationModel();

            try
            {
                if (viewmodel != null)
                {
                    viewmodel.assignedby = um.Userid;

                    um1.Delid = id;
                    DelegationModel um2 = APIDelegation.GetDelegationByDeleid(token, id, out string delerror);
                    um1.Startdate    = um2.Startdate;
                    um1.Enddate      = viewmodel.EndDate;
                    um1.Userid       = um2.Userid;
                    um1.AssignedbyId = um.Userid;
                    um1.Active       = ConDelegation.Active.ACTIVE;
                    APIDelegation.UpdateDelegation(token, um1, out string error);
                }
            }
            catch (Exception ex)
            {
                return(RedirectToAction("Index", "Error", new { error = ex.Message }));
            }
            Session["noti"]        = true;
            Session["notitype"]    = "success";
            Session["notititle"]   = "Update Delegation";
            Session["notimessage"] = "Delegation is updated successfully";

            return(RedirectToAction("SearchPreviousDelegation"));
        }
Exemple #2
0
        public ActionResult SearchPreviousDelegation()
        {
            string    token = GetToken();
            UserModel um    = GetUser();

            DelegationModel         reqms     = new DelegationModel();
            EditDelegationViewModel viewmodel = new EditDelegationViewModel();
            UserModel DelegatedUser           = new UserModel();

            try
            {
                reqms             = APIDelegation.GetPreviousDelegationByDepid(token, um.Deptid, out string error);
                ViewBag.Userid    = reqms.Userid;
                ViewBag.name      = reqms.Username;
                ViewBag.StartDate = reqms.Startdate;
                ViewBag.Enddate   = reqms.Enddate;
                ViewBag.Deleid    = reqms.Delid;
                if (reqms.Userid == 0 || reqms == null)
                {
                    ViewBag.name = "";
                }
                else
                {
                    DelegatedUser = APIUser.GetUserByUserID(reqms.Userid, token, out error);
                    if (DelegatedUser != null && DelegatedUser.Userid != 0)
                    {
                        ViewBag.name = DelegatedUser.Fullname;
                    }
                }
            }
            catch (Exception ex)
            {
                return(RedirectToAction("Index", "Error", new { error = ex.Message }));
            }

            return(View(viewmodel));
        }