Ejemplo 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));
        }
Ejemplo n.º 2
0
        public ActionResult Create([Bind(Include = "FeedbackId,Name,Email,Your_Feedback,Answer")] FeedBack feedBack)
        {
            if (ModelState.IsValid)
            {
                db.FeedBacks.Add(feedBack);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(feedBack));
        }
Ejemplo n.º 3
0
        public ActionResult Create(Service service)
        {
            if (ModelState.IsValid)
            {
                List <FileServiceDetail> fileDetails = new List <FileServiceDetail>();
                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()
                        };
                        if (fileDetail.Extension == ".jpg")
                        {
                            fileDetails.Add(fileDetail);

                            var path = Path.Combine(Server.MapPath("~/App_Data/Upload_service/"), fileDetail.Id + fileDetail.Extension);
                            file.SaveAs(path);
                        }
                        else
                        {
                            TempData["ErrorMessage"] = "Неправильное расширине файла для загрузки(только .jpg)";
                            return(RedirectToAction("Create"));
                        }
                    }
                    else
                    {
                        TempData["ErrorMessage"] = "Должна быть минимум 1 фотография";
                        return(RedirectToAction("Create"));
                    }
                }

                service.FileServiceDetails = fileDetails;
                db.Services.Add(service);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(service));
        }
Ejemplo n.º 4
0
        public ActionResult DeleteConfirmed(int id)
        {
            Feedback feedback = db.Feedbacks.Find(id);

            db.Feedbacks.Remove(feedback);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 5
0
        public ActionResult Create([Bind(Include = "FeedId,FirstName,SecondName,Email,PhoneNumber,Details")] Feedback feedback)
        {
            if (ModelState.IsValid)
            {
                db.Feedbacks.Add(feedback);
                db.SaveChanges();
                return(RedirectToAction("Index", "Home"));
            }

            return(View(feedback));
        }
 public void AddComment(Comment comment)
 {
     _context.Comments.Add(comment);
     _context.SaveChanges();
 }