Exemplo n.º 1
0
        public ActionResult AddBrand(Brand model, HttpPostedFileBase photoPath)
        {
            string PhotoName = "";

            if (photoPath.ContentLength > 0 & photoPath != null)
            {
                PhotoName = Guid.NewGuid().ToString().Replace("-", "") + ".jpg";
                string path = Server.MapPath("~/Upload/" + PhotoName);//yol tutar
                photoPath.SaveAs(path);
            }
            model.Photo = PhotoName;
            if (ModelState.IsValid)//bu yapı tüm properties lerin değerlerini(Atanıp atanmadığını Null olma durumu) kontrol eder
            {
                result.resultint = br.Insert(model);
                if (result.resultint.IsSuccessed)
                {
                    return(RedirectToAction("List"));
                }
                else
                {
                    ViewBag.Mesaj = result.resultint.UserMessage;
                    return(View(model));
                }
            }
            return(View());
        }
        public ActionResult AddBrand(Brand model, HttpPostedFileBase photoPath)
        {
            string photoName = "";

            if (ModelState.IsValid)
            {
                result.resultint = br.Insert(model);
                if (result.resultint.IsSucceded)
                {
                    if (photoPath != null)
                    {
                        photoName = Guid.NewGuid().ToString().Replace("-", "") + ".jpg";
                        string path = Server.MapPath("~/Upload/Brand/" + photoName);
                        photoPath.SaveAs(path);
                    }
                    return(RedirectToAction("List"));
                }
                else
                {
                    ViewBag.Message = result.resultint.UserMessage;
                    return(View(model));
                }
            }
            else
            {
                return(View());
            }
        }
Exemplo n.º 3
0
 public ActionResult AddBrand(Brand model, HttpPostedFileBase photoPath)
 {
     if (Session["UserID"] == null)
     {
         return(RedirectToAction("AdminLogin", "AdminLogin"));
     }
     else
     {
         string PhotoName = "";
         if (photoPath.ContentLength > 0 & photoPath != null)
         {
             PhotoName = Guid.NewGuid().ToString().Replace("-", "") + ".jpg";
             string path = Server.MapPath("~/Upload/" + PhotoName);
             photoPath.SaveAs(path);
         }
         model.Photo = PhotoName;
         if (ModelState.IsValid)
         {
             result.resultint = br.Insert(model);
             if (result.resultint.IsSuccessed)
             {
                 return(RedirectToAction("List"));
             }
             else
             {
                 ViewBag.Mesaj = result.resultint.UserMessage;
                 return(View(model));
             }
         }
         else
         {
             return(View());
         }
     }
 }