public IActionResult Save(TemplateModel template)
        {
            if (!ModelState.IsValid)
            {
                var userID     = _httpContextAccessor.HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;
                var categories = _categoryService.GetOrderedUserCategories(userID, template.IsSpending);

                var viewModel = new TemplateFormViewModel()
                {
                    Template              = template,
                    Categories            = categories,
                    Days                  = new SelectList(GetDaysArray()),
                    DefaultCurrencySymbol = _accountService.GetUserDefaultCurrencySymbol(userID)
                };

                return(View("TemplateForm", viewModel));
            }

            if (template.ID == 0)
            {
                _templateService.AddTemplate(template);
            }
            else
            {
                _templateService.UpdateTemplate(template);
            }

            return(RedirectToAction("TemplateList", "Template"));
        }
Beispiel #2
0
        public void InsertToTemplate(Template template)
        {
            try
            {
                var catsletterTemplate = new Models.Template()
                {
                    Name         = template.Name,
                    FileName     = template.FileName,
                    TemplateType = template.TemplateType
                };

                _templateService.AddTemplate(catsletterTemplate);
            }
            catch (Exception)
            {
            }
        }
 public async Task <int> AddTemplate(Template template)
 {
     return(await TempSvc.AddTemplate(template));
 }