Exemple #1
0
        public ActionResult EditTag(EditTagModel model)
        {
            if (!ModelState.IsValid)
            {
                return(PartialView("_EditTag", model));
            }

            try
            {
                if (model.Id == 0)
                {
                    _tagService.AddOne(model);
                }
                else
                {
                    _tagService.UpdateOne(model);
                }
            }
            catch (Exception exception)
            {
                Log.RegisterError(exception);
            }

            return(RedirectToAction("TagIndex"));
        }
Exemple #2
0
        public ActionResult EditAlbum(EditAlbumModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (model.Id == 0)
                    {
                        var added = _albumService.AddOne(model);
                        model.Id = added.Id;
                        if (model.ParentAlbum.Id != 0)
                        {
                            model.ParentAlbum = _albumService.GetOne(model.ParentAlbum.Id);
                        }
                        ViewBag.Success = $"Альбом {model.TitleRu} был успешно добавлен";
                    }
                    else
                    {
                        if (model.ParentAlbum.Id != 0)
                        {
                            model.ParentAlbum = _albumService.GetOne(model.ParentAlbum.Id);
                        }
                        _albumService.UpdateOne(model);
                        ViewBag.Success = $"Альбом {model.TitleRu} был успешно обновлен";
                    }
                }

                model.ParentAlbums = _albumService.GetAvailableAlbumSelectList(_photoService.GetAll()).Where(x => x.Value != model.Id.ToString());
                model.ViewPatterns = ViewPatternHelper.GetPatterns();
                model.Photos       = new PhotoListModel()
                {
                    Photos = _photoService.GetAll().Where(x => x.AlbumId == model.Id).Select(x => new PhotoModel()
                    {
                        Id             = x.Id,
                        DescriptionEng = x.DescriptionEng,
                        DescriptionRu  = x.DescriptionRu,
                        PhotoPath      = x.PhotoPath,
                        ThumbnailPath  = x.ThumbnailPath,
                        TitleRu        = x.TitleRu,
                        TitleEng       = x.TitleEng,
                        Album          = _albumService.GetOne(model.Id)
                    }).ToList(),
                    ReturnUrl = Url.Action("EditAlbum")
                };
            }
            catch (Exception exception)
            {
                Log.RegisterError(exception);
            }

            return(View(model));
        }
Exemple #3
0
 public ActionResult UpdateTextAttribute(TextAttributeModel model)
 {
     try
     {
         if (model.Id == 0)
         {
             var updated = _textAttrService.AddOne(model);
             model.Id        = updated.Id;
             ViewBag.Success = $"Настройки текста и шрифтов были успешно добавлены";
             return(View("Index", model));
         }
         else
         {
             _textAttrService.UpdateOne(model);
             ViewBag.Success = $"Настройки текста и шрифтов были успешно обновлены";
             return(View("Index", model));
         }
     }
     catch (Exception exception)
     {
         Log.RegisterError(exception);
         return(View("Index", model));
     }
 }