示例#1
0
        public int UpdateAvatar(int userId, string filename)
        {
            var profile = Read(userId);

            if (profile.AvatarLink != null)
            {
                FileUploader.Delete("avatars", profile.AvatarLink);
            }

            profile.AvatarLink = filename;
            return(Save(profile));
        }
示例#2
0
        public ActionResult Delete(int id, FormCollection collection)
        {
            var article = _articleRepository.Read(id);

            if (article == null)
            {
                return(HttpNotFound());
            }

            try
            {
                FileUploader.Delete("articles", article.Logo);
                _articleRepository.Delete(article);

                return(RedirectToAction("Index", "Article"));
            }
            catch
            {
                TempData["error"] = "Возникла ошибка при удалении статьи";
                return(View(article));
            }
        }