Example #1
0
        public ActionResult Add(pb_HashTag model)
        {
            bn_HashTag bnHashTag = new bn_HashTag();
            string     iconPath  = (string)Session["IconPath"];

            if (iconPath != null)
            {
                model.IconPath = iconPath;
            }
            //Check image
            //if (iconPath == "" || iconPath == null)
            //{
            //    ViewBag.Message = "Phải có ít nhất một hình ảnh.";
            //    return View(model);
            //}

            //Check hashtag
            if (bnHashTag.IsExists(model.TagName))
            {
                ViewBag.Message = "This tag has been create, choose another one, please!";
                return(View(model));
            }

            if (ModelState.IsValid)
            {
                bnHashTag.Create(
                    model.UserId,
                    EHashtag_Type.Private,
                    model.TextName,
                    model.TagName,
                    model.Icon,
                    model.Description,
                    model.UserTypes);

                //clear iconpath;
                Session["IconPath"] = null;

                return(RedirectToAction("Index"));
            }

            return(View(model));
        }