Пример #1
0
        public string TransitionRequest(string id, string statusId, string notifyCustomer, string notifyManager)
        {
            int  Id = 0;
            bool notifycustomer, notifymanager = false;

            notifycustomer = notifyCustomer.ToLower().Contains("t") || notifyCustomer.ToLower().Contains("1");
            notifymanager  = notifyManager.ToLower().Contains("f") || notifyManager.ToLower().Contains("1");
            int.TryParse(id, out Id);
            Request request = dao.GetRequests(Id).First();

            request.Modified   = DateTime.Now;
            request.ModifiedBy = 2;//hard coded by as machine
            request.StatusId   = int.Parse(statusId);
            dao.SaveRequest(request);
            if (notifycustomer)
            {
                EmailNotification notification = new EmailNotification()
                {
                    RequestId = request.Id.Value, StatusId = request.StatusId.Value, To = request.Email, Subject = "Request " + id.ToString() + " Updated", Body = "body"
                };
                dao.SaveEmailNotification(notification);
            }

            if (notifymanager)
            {
                EmailNotification notification = new EmailNotification()
                {
                    RequestId = request.Id.Value, StatusId = request.StatusId.Value, To = "*****@*****.**", Subject = "Request " + id.ToString() + " Updated", Body = "body"
                };
                dao.SaveEmailNotification(notification);
            }
            return("Done!");
        }