public ActionResult Edit([Bind(Include = "UserID,Login,Name,Surname,Phone,Password,ConfirmPassword,IsActive,IsAdmin,MyPagination")] User user)
 {
     if (ModelState.IsValid)
     {
         db.Entry(user).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("ViewMyProfile"));
     }
     return(View(user));
 }
Example #2
0
        public async Task <IHttpActionResult> PutAuth(int id, Auth auth)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != auth.Id)
            {
                return(BadRequest());
            }

            db.Entry(auth).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AuthExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #3
0
 public ActionResult Edit([Bind(Include = "CategoryID,Name,ParentcategoryID")] Category category)
 {
     if (ModelState.IsValid)
     {
         db.Entry(category).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(category));
 }
 public ActionResult Edit([Bind(Include = "AdminMessageID,Title,Content")] AdminMessage adminMessage)
 {
     if (ModelState.IsValid)
     {
         db.Entry(adminMessage).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(adminMessage));
 }
Example #5
0
 public ActionResult Edit([Bind(Include = "ForbiddenWordID,Name")] ForbiddenWord forbiddenWord)
 {
     if (ModelState.IsValid)
     {
         db.Entry(forbiddenWord).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(forbiddenWord));
 }
Example #6
0
 public ActionResult Edit([Bind(Include = "ProductName,Description,Price,Photo,ID,AuthorID,DataCreated")] Ad ad)
 {
     if (ModelState.IsValid)
     {
         db.Entry(ad).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(ad));
 }
 public ActionResult Edit([Bind(Include = "AttributeID,Type,Name,Value,CategoryID")] Ads.Models.Attribute attribute)
 {
     if (ModelState.IsValid)
     {
         db.Entry(attribute).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CategoryID = new SelectList(db.Categories, "CategoryID", "Name", attribute.CategoryID);
     return(View(attribute));
 }
Example #8
0
 public ActionResult Update(Ad ad)
 {
     if (ad != null)
     {
         if (ModelState.IsValid)
         {
             db.Entry(ad).State = EntityState.Modified;
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
     }
     return(View(ad));
 }
        public ActionResult Edit([Bind(Include = "AdID,Title,Content,DateOfInsert,CategoryID,UserID")] Ad ad, HttpPostedFileBase file)
        {
            //--------------------------------Dodawanie multimediow ---------------------------

            var originalDirectory = new DirectoryInfo(string.Format("{0}Images\\Uploads", Server.MapPath(@"\")));

            var pathString1 = Path.Combine(originalDirectory.ToString(), "Ads");
            var pathString2 = Path.Combine(originalDirectory.ToString(), "Ads" + ad.AdID.ToString());
            var pathString3 = Path.Combine(originalDirectory.ToString(), "Ads" + ad.AdID.ToString() + "\\Thumbs");
            var pathString4 = Path.Combine(originalDirectory.ToString(), "Ads" + ad.AdID.ToString() + "\\Galery");
            var pathString5 = Path.Combine(originalDirectory.ToString(), "Ads" + ad.AdID.ToString() + "\\Galery\\Thumbs");

            if (!Directory.Exists(pathString1))
            {
                Directory.CreateDirectory(pathString1);
            }
            if (!Directory.Exists(pathString2))
            {
                Directory.CreateDirectory(pathString2);
            }
            if (!Directory.Exists(pathString3))
            {
                Directory.CreateDirectory(pathString3);
            }
            if (!Directory.Exists(pathString4))
            {
                Directory.CreateDirectory(pathString4);
            }
            if (!Directory.Exists(pathString5))
            {
                Directory.CreateDirectory(pathString5);
            }

            if (file != null && file.ContentLength > 0)
            {
                string ext = file.ContentType.ToLower();

                if (ext != "image/jpg" && ext != "image/jpeg" && ext != "image/pjpeg" && ext != "image/gif" && ext != "image/png")
                {
                    ModelState.AddModelError("", "Plik nie zostal załadowany - złe rozszerzenie");
                    return(View(ad));
                }

                string imageName = file.FileName;
                ad.MediaPath = imageName;
                db.SaveChanges();

                var path  = string.Format("{0}\\{1}", pathString2, imageName);
                var path2 = string.Format("{0}\\{1}", pathString3, imageName);

                file.SaveAs(path);

                WebImage img = new WebImage(file.InputStream);
                img.Resize(200, 200);
                img.Save(path2);
            }
            /////////////////////////
            if (ModelState.IsValid)
            {
                ad.DateOfInsert    = DateTime.Now;
                ad.UserID          = Convert.ToInt16(Session["UserID"]);
                db.Entry(ad).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.UserID = new SelectList(db.Users, "UserID", "Login", ad.UserID);

            return(View(ad));
        }