コード例 #1
0
        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"));
        }
コード例 #2
0
        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);
                }
            }
        }
コード例 #3
0
        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"));
        }