Пример #1
0
        public ActionResult Create(AwardView awardView)
        {
            Award award = null;

            try
            {
                if (ModelState.IsValid && awardView.Image != null)
                {
                    string fileName = SetPhotoPath(awardView);
                    string path     = "/img/" + Path.GetFileName(awardView.Image.FileName);

                    award = new Award()
                    {
                        Title       = awardView.Title,
                        Description = awardView.Description,
                        ImagePath   = path
                    };

                    Repository.AddAward(award);
                    Repository.Save();
                    return(RedirectToAction("Index"));
                }
            }
            catch (DataException)
            {
                ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
            }
            return(View(award));
        }
Пример #2
0
 public bool AddAward(AwardDTO award)
 {
     try
     {
         _repository.AddAward(award);
     }
     catch
     {
         return(false);
     }
     return(true);
 }