Beispiel #1
0
        public IActionResult ChangeEmployeeStatus([Bind("MemberId,DutyStatus,ParentComponentId")] ChangeEmployeeStatusModalViewComponentViewModel form)
        {
            // validate the ModelState
            if (ModelState.IsValid)
            {
                // retrieve the member from the Repo
                Member m = unitOfWork.Members.GetMemberWithPosition(Convert.ToInt32(form.MemberId));
                // retrieve the DutyStatus
                DutyStatus status = unitOfWork.MemberDutyStatus.Get(Convert.ToInt32(form.DutyStatus));

                // set the Member status to the new Status
                m.DutyStatusId = Convert.ToInt32(form.DutyStatus);
                // save changes to the repo
                m.LastModified     = DateTime.Now;
                m.LastModifiedById = Convert.ToInt32(User.Claims.FirstOrDefault(claim => claim.Type == "MemberId").Value);
                unitOfWork.Complete();
                // return success object so Client can refresh the RosterManager
                return(Json(new { success = true }));
            }
            else
            {
                // Invalid ModelState, re-populate VM lists and return the ViewComponent
                form.StatusList = unitOfWork.MemberDutyStatus.GetMemberDutyStatusSelectListItems();
                form.Member     = unitOfWork.Members.Get(Convert.ToInt32(form.MemberId));
                return(ViewComponent("ChangeEmployeeStatus", form));
            }
        }
Beispiel #2
0
        // ChangeEmployeeDutyStatusModalViewComponent

        public IActionResult GetChangeEmployeeStatusModalViewComponent(int memberId)
        {
            Member m = unitOfWork.Members.GetMemberWithPosition(memberId);

            if (m != null)
            {
                List <MemberDutyStatusSelectListItem>           statusList = unitOfWork.MemberDutyStatus.GetMemberDutyStatusSelectListItems();
                ChangeEmployeeStatusModalViewComponentViewModel vm         = new ChangeEmployeeStatusModalViewComponentViewModel(m, statusList);
                return(ViewComponent("ChangeEmployeeStatusModal", vm));
            }
            else
            {
                return(NotFound());
            }
        }
 public IViewComponentResult Invoke(ChangeEmployeeStatusModalViewComponentViewModel vm)
 {
     return(View(vm));
 }