public ActionResult Create(FormCollection collection)
 {
     try
     {
         dc.Image_Insert(collection["Alt"], collection["Description"], collection["Url"], Session["Username"].ToString());
         return(RedirectToAction("Index"));
     }
     catch
     {
         ViewBag.Message = "Error in image creation";
         if (Request.IsAjaxRequest())
         {
             return(PartialView());
         }
         else
         {
             return(View());
         }
     }
 }
Example #2
0
        public async Task <ActionResult> Create(string Name, string Description, HttpPostedFileBase Parvandeh, int Product = 0, int Post = 0)
        {
            try
            {
                var _Bytes = new byte[Parvandeh.ContentLength];
                Parvandeh.InputStream.Read(_Bytes, 0, Parvandeh.ContentLength);

                dc.Image_Insert(null, Name, _Bytes, Description, Product, Post);
                return(RedirectToAction("Index"));
            }
            catch (Exception e)
            {
                ViewBag.Message = "خطا در بارگزاری فایل";
                if (Request.IsAjaxRequest())
                {
                    return(PartialView());
                }
                return(View());
            }
        }