示例#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));
            }
        }
        private static DutyStatus[] GenerateDutyPerformance(DutyStatus status)
        {
            var output = new DutyStatus[7];

            for (var i = 0; i < 7; i++)
            {
                output[i] = status;
            }

            return output;
        }
示例#3
0
        public static string DutyStatusToString(DutyStatus Input)
        {
            switch (Input)
            {
            case DutyStatus.ON_DUTY:
                return("On Duty");

            case DutyStatus.OFF_DUTY:
                return("Off Duty");

            case DutyStatus.OOS:
                return("Out of Service");

            default:
                throw new Exception("Invalid Duty Status Value");
            }
        }
示例#4
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            DutyStatus status = (DutyStatus)value;

            switch (status)
            {
            case DutyStatus.Ongoing:
                return(ColorConverter.ConvertFromString("#BB4D4D"));

            case DutyStatus.Paused:
                return(ColorConverter.ConvertFromString("#CFC739"));

            case DutyStatus.Completed:
                return(ColorConverter.ConvertFromString("#49BF4B"));

            default:
                return(Colors.Pink);
            }
        }
示例#5
0
 public IActionResult Create([Bind("DutyStatusId,DutyStatusName,HasPolicePower,IsExceptionToNormalDuty,Abbreviation")] DutyStatus dutyStatus, string returnUrl)
 {
     if (ModelState.IsValid)
     {
         unitOfWork.MemberDutyStatus.Add(dutyStatus);
         unitOfWork.Complete();
         TempData["Status"]  = "Success!";
         TempData["Message"] = "Status successfully created.";
         if (!String.IsNullOrEmpty(returnUrl))
         {
             return(Redirect(returnUrl));
         }
         else
         {
             return(RedirectToAction(nameof(Index)));
         }
     }
     ViewBag.ReturnUrl = returnUrl;
     return(View(dutyStatus));
 }
示例#6
0
        public IActionResult Edit(int id, [Bind("DutyStatusId,DutyStatusName,HasPolicePower,IsExceptionToNormalDuty,Abbreviation")] DutyStatus dutyStatus, string returnUrl)
        {
            if (id != dutyStatus.DutyStatusId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    DutyStatus toEdit = unitOfWork.MemberDutyStatus.Get(id);
                    toEdit.DutyStatusName = dutyStatus.DutyStatusName;
                    toEdit.HasPolicePower = dutyStatus.HasPolicePower;
                    toEdit.Abbreviation   = dutyStatus.Abbreviation;
                    unitOfWork.Complete();
                    TempData["Status"]  = "Success!";
                    TempData["Message"] = "Status successfully updated.";
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DutyStatusExists(dutyStatus.DutyStatusId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                if (!String.IsNullOrEmpty(returnUrl))
                {
                    return(Redirect(returnUrl));
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewBag.ReturnUrl = returnUrl;
            return(View(dutyStatus));
        }
示例#7
0
        public IActionResult DeleteConfirmed(int id, string returnUrl)
        {
            DutyStatus toRemove = unitOfWork.MemberDutyStatus.GetDutyStatusWithMemberCount((Int32)id);

            if (toRemove != null && toRemove.Members.Count() == 0)
            {
                unitOfWork.MemberDutyStatus.Remove(toRemove);
                unitOfWork.Complete();
                TempData["Status"]  = "Success!";
                TempData["Message"] = "Status successfully deleted.";
            }
            else
            {
                ViewBag.Status    = "Warning!";
                ViewBag.Message   = "You cannot delete a Duty Status with active Members.";
                ViewBag.ReturnUrl = returnUrl;
                return(View(toRemove));
            }
            if (!String.IsNullOrEmpty(returnUrl))
            {
                return(Redirect(returnUrl));
            }
            return(RedirectToAction(nameof(Index)));
        }
示例#8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DutyStatusApiResult"/> class.
 /// </summary>
 /// <param name="_dutyStatus">The duty status.</param>
 public DutyStatusApiResult(DutyStatus _dutyStatus)
 {
     Name           = _dutyStatus.DutyStatusName;
     Abbreviation   = _dutyStatus.Abbreviation.ToString();
     HasPolicePower = _dutyStatus.HasPolicePower;
 }