Ejemplo n.º 1
0
        public ActionResult Edit(int id, LastDay lastDay)
        {
            lastDay.ValidateManager(ModelState);
            lastDay.SetRequestersEmail(User);

            if (ModelState.IsValid)
            {
                LastDayNotice lastDayNotice = new LastDayNotice(lastDay, "Update");

                if (TryValidateModel(lastDayNotice) == true)
                {
                    if (lastDay.Immediate == true && (lastDay.Decommissioned == false || lastDay.ServiceRequest == false))
                    {
                        lastDay.Decommission();
                    }

                    if (lastDay.Suppress == false)
                    {
                        Mailer mailer = new Mailer(MessageTemplate.LastDayEmployee, true);

                        if (lastDay.IsContingent == true)
                        {
                            mailer = new Mailer(MessageTemplate.LastDayContingent, true);
                        }

                        mailer.SetFromAddress(lastDay.RequestersEmail);
                        mailer.AddRecipient(lastDay.ManagersEmail);

                        if (lastDay.ITaaS == true)
                        {
                            mailer.AddITaaSNotificationGroup();
                        }

                        mailer.SendMessage("LastDayNotice", lastDayNotice, lastDayNotice.Subject);
                    }

                    db.Entry(lastDay).State = EntityState.Modified;
                    db.SaveChanges();

                    return(RedirectToAction("Index"));
                }

                ModelState.AddModelError("MailNotice", "Mail Notice Error");
            }

            return(View(lastDay));
        }
Ejemplo n.º 2
0
        public ActionResult DeleteConfirmed(int id)
        {
            LastDay lastDay = db.LastDays.Find(id);

            LastDayNotice lastDayNotice = new LastDayNotice(lastDay, "Cancel");

            if (TryValidateModel(lastDayNotice) == true)
            {
                if (lastDay.Suppress == false)
                {
                    Mailer mailer = new Mailer(MessageTemplate.LastDayEmployee, true);

                    if (lastDay.IsContingent == true)
                    {
                        mailer = new Mailer(MessageTemplate.LastDayContingent, true);
                    }

                    mailer.SetFromAddress(lastDay.RequestersEmail);
                    mailer.AddRecipient(lastDay.ManagersEmail);

                    if (lastDay.ITaaS == true)
                    {
                        mailer.AddITaaSNotificationGroup();
                    }

                    mailer.SendMessage("LastDayNotice", lastDayNotice, lastDayNotice.Subject);
                }

                db.LastDays.Remove(lastDay);
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("MailNotice", "Mail Notice Error");

            return(View());
        }
Ejemplo n.º 3
0
 public ActionResult LastDayNotice(LastDayNotice lastDayNotice)
 {
     return(View(lastDayNotice));
 }
Ejemplo n.º 4
0
        public ActionResult LastDayRequest(LastDay lastDay)
        {
            lastDay.Validate(ModelState, User);

            //if (db.LastDays.Any(x => x.EmailAddress == lastDay.EmailAddress))
            //{
            //    ModelState.AddModelError("Request", "Last Day Already Requested");
            //}

            if (ModelState.IsValid)
            {
                LastDayNotice lastDayNotice = new LastDayNotice(lastDay, "New");

                if (TryValidateModel(lastDayNotice) == true)
                {
                    if (lastDay.Immediate == true)
                    {
                        lastDay.Decommission();
                    }
                    else
                    {
                        if (db.GSCUsers.Any(x => x.GUID == lastDay.GUID && x.Active == true))
                        {
                            foreach (GSCUser gscUser in db.GSCUsers.Where(x => x.GUID == lastDay.GUID && x.Active == true))
                            {
                                var gscClient = db.GSCClients.Find(gscUser.GSCClientID);

                                gscUser.GSCClient = gscClient;
                                gscUser.EndDate   = lastDay.EndDate;
                                gscUser.MailExternalCompany();
                            }
                        }
                    }

                    if (lastDay.Suppress == false)
                    {
                        Mailer mailer = new Mailer(MessageTemplate.LastDayEmployee, true);

                        if (lastDay.IsContingent == true)
                        {
                            mailer = new Mailer(MessageTemplate.LastDayContingent, true);
                        }

                        mailer.SetFromAddress(lastDay.RequestersEmail);
                        mailer.AddRecipient(lastDay.ManagersEmail);

                        if (lastDay.ITaaS == true)
                        {
                            mailer.AddITaaSNotificationGroup();
                        }

                        mailer.SendMessage("LastDayNotice", lastDayNotice, lastDayNotice.Subject);
                    }

                    db.LastDays.Add(lastDay);
                    db.SaveChanges();

                    return(RedirectToAction("Index"));
                }

                ModelState.AddModelError("MailNotice", "Mail Notice Error");
            }

            return(View(lastDay));
        }