Exemple #1
0
        public ActionResult Add(Activity act, HttpPostedFileBase picture)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (picture != null)
                    {
                        ImageClass.ImageMethod(picture, "Activity", out string bigImageName, out string smallImageName, out string tempData);

                        if (tempData != null)
                        {
                            TempData["warning"] = tempData;
                        }
                        act.BigImageName   = bigImageName;
                        act.SmallImageName = smallImageName;
                    }

                    ActivityDao aDao    = new ActivityDao();
                    bool        isExist = aDao.ActivityExist(act.Name);
                    if (isExist == false)
                    {
                        UserDao uDao = new UserDao();
                        act.Author = uDao.GetByLogin(User.Identity.Name);

                        aDao.Create(act);
                    }
                    else
                    {
                        TempData["warning"] = "Aktivita pod tímto názvem již existuje!";
                        return(View("Create", act));
                    }
                }
                else
                {
                    return(View("Create", act));
                }

                if (TempData["warning"] == null)
                {
                    TempData["succes"] = "Nová aktivita " + act.Name + " úspěšně přidána.";
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }

            return(RedirectToAction("Index"));
        }
 public static int Create(ActivityInfo act, ref string msg)
 {
     return(_act.Create(act, ref msg));
 }