Exemplo n.º 1
0
        public IHttpActionResult PutFeedBack(int id, FeedBack feedBack)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != feedBack.FeedbackId)
            {
                return(BadRequest());
            }

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

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!FeedBackExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 2
0
        public ActionResult Edit(Service service)
        {
            if (ModelState.IsValid)
            {
                //New Files
                for (int i = 0; i < Request.Files.Count; i++)
                {
                    var file = Request.Files[i];

                    if (file != null && file.ContentLength > 0)
                    {
                        var fileName = Path.GetFileName(file.FileName);
                        FileServiceDetail fileDetail = new FileServiceDetail()
                        {
                            FileName  = fileName,
                            Extension = Path.GetExtension(fileName),
                            Id        = Guid.NewGuid(),
                            ServiceId = service.ServiceId
                        };
                        if (fileDetail.Extension == ".jpg")
                        {
                            var path = Path.Combine(Server.MapPath("~/App_Data/Upload_service/"), fileDetail.Id + fileDetail.Extension);
                            file.SaveAs(path);
                        }
                        else
                        {
                            TempData["ErrorMessage"] = "Неправильное расширине файла для загрузки(только .jpg)";
                            return(RedirectToAction("Edit"));
                        }
                        db.Entry(fileDetail).State = EntityState.Added;
                    }
                    else
                    {
                        TempData["ErrorMessage"] = "Должна быть минимум 1 фотография";
                        return(RedirectToAction("Create"));
                    }
                }

                db.Entry(service).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(service));
        }
Exemplo n.º 3
0
 public ActionResult Edit([Bind(Include = "FeedbackId,Name,Email,Your_Feedback,Answer")] FeedBack feedBack)
 {
     if (ModelState.IsValid)
     {
         db.Entry(feedBack).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(feedBack));
 }