Exemple #1
0
        public ActionResult Detail(int id)
        {
            IMessageTemplateRepository model = new MessageTemplateRepository();

            ViewData.Model = model.getById(id);
            return(View());
        }
Exemple #2
0
        public ActionResult edit(FormCollection collection)
        {
            //Generate new Committee object for form if error
            MessageTemplateRepository message_rep = new MessageTemplateRepository();
            MessageTemplate           message     = new MessageTemplate();

            //GET Committee
            try
            {
                message             = message_rep.getById(Int32.Parse(collection["message_id"]));
                TempData["message"] = message;
            }
            catch (Exception exception)
            {
                //IF THERE IS A MESS UP, RETURN ERROR TO FRONT
                TempData["flash"] = "Unable to retrieve message: " + exception.Message;
                return(RedirectToAction("edit", new { controller = "MessageTemplate", id = collection["message_id"] }));
            }


            //UPDATE Committee
            try
            {
                return(messageTemplateFormProcess(message, message_rep, collection));
            }
            catch (Exception exception)
            {
                //IF THERE IS A MESS UP, RETURN ERROR TO FRONT
                TempData["flash"] = "Unable to update message: " + exception.Message;
                return(RedirectToAction("edit", new { controller = "MessageTemplate", id = collection["message_id"] }));
            }
        }
Exemple #3
0
        //
        // GET: /MessageTemplate/

        public ActionResult Index()
        {
            IMessageTemplateRepository model = new MessageTemplateRepository();

            ViewData["all_messages"] = model.getAll();
            return(View());
        }
Exemple #4
0
        public ActionResult delete(int id)
        {
            MessageTemplateRepository m_rep = new MessageTemplateRepository();
            MessageTemplate           m     = new MessageTemplate();

            //GET Committee
            try
            {
                m = m_rep.getById(id);
            }
            catch (Exception exception)
            {
                //IF THERE IS A MESS UP, RETURN ERROR TO FRONT
                TempData["flash"] = "Unable to retrieve message: " + exception.Message;
                return(RedirectToAction("Index"));
            }


            //DELETE Committee
            try
            {
                m_rep.delete(m);
                TempData["flash"] = "Deleted message.";
                return(RedirectToAction("Index"));
            }
            catch (Exception exception)
            {
                TempData["flash"] = "Unable to delete message: " + exception.Message;
                return(RedirectToAction("Index"));
            }
        }
 //private ConfigOptions _options;
 public InitialiseWorkflowData(IHostingEnvironment env, TriggerRepository context,
                               ModulesRepository module, WFStateRepository wfstate, MessageTemplateRepository message)
 {
     _context = context;;
     _env     = env;
     _module  = module;
     _wfstate = wfstate;
     _message = message;
 }
Exemple #6
0
        public ActionResult edit(int id)
        {
            MessageTemplateRepository message_rep = new MessageTemplateRepository();

            ViewData["message_id"] = id.ToString();
            ViewData.Model         = message_rep.getById(id);
            ViewData["edit"]       = true;

            return(View());
        }
Exemple #7
0
        public UnitOfWork(RadixNotificationContext context)
        {
            this._context = context;

            AdhocMessages             = new AdhocMessageRepository(_context);
            Messages                  = new MessageRepository(_context);
            MessageTypes              = new MessageTypeRepository(_context);
            MessageTemplates          = new MessageTemplateRepository(_context);
            NotificationPreferrences  = new NotificationPreferrenceRepository(_context);
            NotificationSubscriptions = new NotificationSubscriptionRepository(_context);
            ServiceConfigurations     = new ServiceConfigurationRepository(_context);
        }
        public ActionResult Delete(int id)
        {
            using (var context = new InnostarModelsContext())
            {
                var repository = new MessageTemplateRepository(context);
                var template   = repository._Get(e => e.Id == id).FirstOrDefault();

                if (!template.Blocked)
                {
                    repository._Delete(template);
                    repository._Save();
                }
            }

            return(RedirectToAction("Index"));
        }
        public string _TextTemplate(int id)
        {
            using (var context = new InnostarModelsContext())
            {
                var repository = new MessageTemplateRepository(context);
                var template   = repository._Get(e => e.Id == id).ToList();

                if (template.Any())
                {
                    return(template.FirstOrDefault().Message);
                }
                else
                {
                    return(string.Empty);
                }
            }
        }
        private IEnumerable <SelectListItem> GetMessageTemplates()
        {
            using (var context = new InnostarModelsContext())
            {
                var repository = new MessageTemplateRepository(context);
                var templates  = repository._All.Where(e => e.SpecialTemplate == 0).ToList();
                var result     = new List <SelectListItem>();
                foreach (var template in templates)
                {
                    result.Add(new SelectListItem
                    {
                        Text  = template.Title,
                        Value = template.Id.ToString(CultureInfo.InvariantCulture)
                    });
                }

                return(result);
            }
        }
        public ActionResult Create(MessageTemplateViewModel model)
        {
            using (var context = new InnostarModelsContext())
            {
                var repository = new MessageTemplateRepository(context);
                var template   = new MessageTemplate
                {
                    Blocked         = false,
                    SpecialTemplate = 0,
                    Message         = model.Text,
                    Title           = model.Title
                };

                repository._Insert(template);
                repository._Save();
            }

            return(RedirectToAction("Index"));
        }
        public ActionResult Edit(MessageTemplateViewModel model)
        {
            using (var context = new InnostarModelsContext())
            {
                var repository = new MessageTemplateRepository(context);
                var template   = repository._Get(e => e.Id == model.Id).FirstOrDefault();

                template.Message = model.Text;

                if (!model.Blocked)
                {
                    template.Title = model.Title;
                }

                repository._Update(template);
                repository._Save();
            }

            return(RedirectToAction("Index"));
        }
Exemple #13
0
        public ActionResult create(FormCollection collection)
        {
            //Generate new Committee object
            MessageTemplateRepository message_template_rep = new MessageTemplateRepository();
            MessageTemplate           message = new MessageTemplate();

            ViewData["edit"]    = false;
            ViewData["message"] = message;

            try
            {
                return(messageTemplateFormProcess(message, message_template_rep, collection));
            }
            catch (Exception exception)
            {
                //IF THERE IS A MESS UP, RETURN ERROR TO FRONT
                TempData["flash"] = "Unable to create message template: " + exception.Message;
                return(RedirectToAction("create"));
            }
        }
        public static MessageTemplate GetMessageTemplateWithReplacedBody(MessageTemplateTypes messageTemplateType, Dictionary <string, string> values)
        {
            using (MindCornersEntities context = new MindCornersEntities())
                using (MessageTemplateRepository messageTemplateRepository = new MessageTemplateRepository(context, Guid.Empty, null))
                {
                    var messageTemplate = messageTemplateRepository.GetMessageTemplateByType(messageTemplateType);
                    if (messageTemplate != null)
                    {
                        StringBuilder sb = new StringBuilder(messageTemplate.Body);
                        foreach (var value in values)
                        {
                            sb.Replace(value.Key, value.Value);
                        }
                        messageTemplate.BodyReplaced = sb.ToString();
                        return(messageTemplate);
                    }
                }

            return(null);
        }
Exemple #15
0
        //PROCESS EDIT AND CREATE FORMS
        private ActionResult messageTemplateFormProcess(MessageTemplate message, MessageTemplateRepository message_rep, FormCollection collection)
        {
            try
            {
                message.Title     = collection["title"];
                message.Body      = collection["body"];
                message.DaysDelta = Convert.ToInt32(collection["days_delta"]);
                if (collection["disable"] != null)                                        //Only appears on the edit form
                {
                    message.Disabled = collection["disable"].ToString().Contains("true"); //Check box returns 2 values, one of which is whether it's ticked and the other is "Remember me"
                }
                message_rep.save(message);

                TempData["flash"] = "Message Template saved: " + message.Title;

                return(RedirectToAction("Detail", new { ID = message.Id }));
            }
            catch (Exception exception)
            {
                throw new Exception("A data entry problem has occurred.");
            }
        }
Exemple #16
0
 public MessageTemplateServices()
 {
     _messageTemplateRepository = new MessageTemplateRepository();
 }