Beispiel #1
0
        /// <summary>
        /// Starts the new flex type rule.
        /// </summary>
        /// <param name="flexType">Flex type to start.</param>
        /// <returns>Next rule reference.</returns>
        public IFluentFlexAll WithFlexType(FlexType flexType)
        {
            currentFlexType = flexType;
            Dirty();

            return(this);
        }
 public ActionResult DeleteFlexType(FlexType flexType)
 {
     if (uow.FlexTypeRepo.Exists(flexType.Id))
     {
         uow.FlexTypeRepo.Delete(flexType);
         uow.SaveChanges();
         return(NoContent());
     }
     return(NotFound());
 }
 public IActionResult PutFlexType(Guid?id, FlexType flexType)
 {
     if (id != flexType.Id)
     {
         return(BadRequest());
     }
     if (uow.FlexTypeRepo.Exists(id))
     {
         uow.FlexTypeRepo.Put(flexType, flexType.Id);
         uow.SaveChanges();
         return(NoContent());
     }
     return(NotFound());
 }
Beispiel #4
0
        public void SendApproveFlexEmails(Flex flex)
        {
            User user = uow.UserRepo.GetById(flex.UserId);
            User leadership = uow.UserRepo.GetById(user.ReportToUserId);

            string emailBody2User = $"Hi {user.FirstName} {user.LastName}, <br/><br/>Your flex request ";

            string emailBody2Leadership = $"Hi {leadership.FirstName} {leadership.LastName}, <br/><br/>Flex Request submitted by {user.FirstName} {user.LastName} ({user.NTLogin})  of your team";

            string msgContent;
            FlexType flexType = uow.FlexTypeRepo.GetById(flex.FlexTypeId);
            if (flexType.Name == "Shift Slide" || flexType.Name == "Pre-Arranged Shift Slide")
            {
                emailBody2User += $"Shift Slide request to move your schedule for { flex.Hours} hours ";
                msgContent = (flex.IsForward) ? "Forward" : "Backward" + $"<br>from { flex.StartDateTime} < br /> to { flex.EndDateTime} is ";
                    
                emailBody2User += msgContent + "approved by your manager.";
                emailBody2Leadership += $" has submitted a Shift Slide request to move schedule for {flex.Hours} hours" + msgContent + "approved by you.";
            }
            else if (flexType.Name == "Shift Swap")
            {
                User coWorker = uow.UserRepo.GetById(flex.CoWorkerId);
                string email2CoWorker = emailBody2User + $" CoWorker  { user.FirstName } { user.LastName } ({user.NTLogin})  has requested a Shift Swap on { flex.StartDateTime.Date } from { flex.StartDateTime.TimeOfDay } to { flex.EndDateTime.TimeOfDay } with your shift on { flex.StartDateTime.Date} from { flex.AnotherStartDateTime.TimeOfDay } to { flex.AnotherEndDateTime.TimeOfDay }.  This request is waiting for your approval.";
                EmailMessage msg = new EmailMessage(new string[] { coWorker.EmailAddress }, "Email to Co-Worker", email2CoWorker);
                emailSender.SendEmail(msg);

                msgContent = $"shift < br>on { flex.StartDateTime.Date } from { flex.StartDateTime.TimeOfDay } to { flex.EndDateTime.TimeOfDay } with Co-Worker { coWorker.FirstName } { coWorker.LastName } ({coWorker.NTLogin}) shift on { flex.AnotherStartDateTime.Date} from { flex.AnotherStartDateTime.TimeOfDay } to { flex.AnotherEndDateTime.TimeOfDay }";

                emailBody2User += $"Shift Swap request to move your " + msgContent + "is approved by your Manager.";
                emailBody2Leadership += $" has submitted a Shift Swap request to move " + msgContent + "is approved by you.";
            }
            else if (flexType.Name == "Self-Shift Swap")
            {
                msgContent = $"shift < br> from { flex.StartDateTime.TimeOfDay } to { flex.EndDateTime.TimeOfDay } on { flex.StartDateTime.Date } with shift on { flex.AnotherStartDateTime.Date} ";

                emailBody2User += $"Shift Swap request to move your " + msgContent + "is approved by your Manager.";
                emailBody2Leadership += $" has submitted a Shift Swap request to move " + msgContent + "is approved by you.";
            }
            var message = new EmailMessage(new string[] { user.EmailAddress }, "Email to User who applied PTO", emailBody2User);
            emailSender.SendEmail(message);
            message = new EmailMessage(new string[] { leadership.EmailAddress }, "Email to Leadership of User", emailBody2Leadership);
            emailSender.SendEmail(message);
        }
        public IActionResult PostFlex(Flex flex)
        {
            quotaService.SendFlexEmails(flex);
            Status waitlistStatus = uow.StatusRepo.GetAll().Where(status => status.Name == "WaitList").FirstOrDefault();

            flex.StatusId = waitlistStatus.Id;

            FlexType shiftSwap = uow.FlexTypeRepo.GetByName("Shift Swap");

            if (flex.FlexTypeId == shiftSwap.Id)
            {
                Guid guid = CreateCoWorkerFlex(flex);
                flex.CoWorkerFlexId = guid;
                Status pending = uow.StatusRepo.GetByName("Pending");
                flex.StatusId = pending.Id;
            }
            uow.FlexRepo.Post(flex);
            uow.SaveChanges();
            return(CreatedAtAction(nameof(GetFlex), new { id = flex.Id }, flex));
        }
        public IActionResult PutFlex(Guid?id, Flex flex)
        {
            if (id != flex.Id)
            {
                return(BadRequest());
            }
            if (uow.FlexRepo.Exists(id))
            {
                Flex flexOld = uow.FlexRepo.GetById(flex.Id);

                FlexType shiftSwap        = uow.FlexTypeRepo.GetByName("Shift Swap");
                FlexType shiftSwapRequest = uow.FlexTypeRepo.GetByName("Shift Swap Request");
                if (flex.FlexTypeId == shiftSwap.Id)
                {
                    Flex coWorkerFlex = uow.FlexRepo.GetById(flex.CoWorkerFlexId);
                    if (flex.CoWorkerId != flexOld.CoWorkerId && coWorkerFlex.FlexTypeId == shiftSwapRequest.Id)
                    {
                        //Delete the old Co-Worker Flex Entry; Need to send an email to old Co-Worker about the updates.
                        coWorkerFlex.IsActive = false;
                        uow.FlexRepo.Put(coWorkerFlex, coWorkerFlex.Id);
                        uow.SaveChanges();
                        quotaService.SendEmailsOnCoWorkerChange(coWorkerFlex);

                        //Create another request  for CoWorker Id
                        Guid coWorkerFlexId = CreateCoWorkerFlex(flex);
                        flex.CoWorkerFlexId = coWorkerFlexId;
                    }
                }
                Status approved = uow.StatusRepo.GetByName("Approved");
                if (flex.StatusId != flexOld.StatusId && flex.StatusId == approved.Id)
                {
                    quotaService.SendApproveFlexEmails(flex);
                }
                uow.FlexRepo.Put(flex, flex.Id);
                uow.SaveChanges();
                return(NoContent());
            }
            return(NotFound());
        }
        private Guid CreateCoWorkerFlex(Flex flex)
        {
            Guid userId = flex.UserId;

            flex.UserId     = flex.CoWorkerId;
            flex.CoWorkerId = userId;

            FlexType shiftSwapRequest = uow.FlexTypeRepo.GetByName("Shift Swap Request");

            flex.FlexTypeId = shiftSwapRequest.Id;

            flex.CoWorkerFlexId = flex.Id;

            Guid guid = Guid.NewGuid();

            flex.Id = guid;
            Status pending = uow.StatusRepo.GetByName("Pending");

            flex.StatusId = pending.Id;
            uow.FlexRepo.Post(flex);
            uow.SaveChanges();
            return(guid);
        }
 public ActionResult <FlexType> PostFlexType(FlexType flexType)
 {
     uow.FlexTypeRepo.Post(flexType);
     uow.SaveChanges();
     return(CreatedAtAction(nameof(GetFlexType), new { id = flexType.Id }, flexType));
 }
Beispiel #9
0
 public FlexNode()
 {
     type = FlexType.Straight;
     idx  = 0;
     time = 0;
 }
Beispiel #10
0
 public FlexNode(int i, FlexType t, float d)
 {
     idx  = i;
     type = t;
     time = d;
 }