public ActionResult Create(Photo_CheckPoint photo_CheckPoint) { PhotoUtil utilPhoto = new PhotoUtil(); HttpFileCollectionBase image = Request.Files; if (image[0].FileName != "") { photo_CheckPoint.Photo_Code = utilPhoto.EncodeImage(image[0]); photo_CheckPoint.Photo_Extension = Path.GetExtension(image[0].FileName); if (ModelState.IsValid) { _context.Photo_CheckPoints.Add(photo_CheckPoint); _context.SaveChanges(); return(RedirectToAction("List", "Photo_CheckPoint", new { checkPointID = photo_CheckPoint.CheckPointId })); } } var checkPoint = _context.Beacons.SingleOrDefault(m => m.ID == photo_CheckPoint.CheckPointId); PhotoCheckPointViewModel data = new PhotoCheckPointViewModel() { Photo_CheckPoint = photo_CheckPoint, CheckPoint = checkPoint }; return(View("New", data)); }
public IHttpActionResult PutPhoto_Place(int id, Photo_CheckPoint photo_Place) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != photo_Place.ID) { return(BadRequest()); } db.Entry(photo_Place).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!Photo_PlaceExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetPhoto_Place(int id) { Photo_CheckPoint photo_Place = db.Photo_CheckPoints.Find(id); if (photo_Place == null) { return(NotFound()); } return(Ok(photo_Place)); }
public ActionResult Edit(int ID) { Photo_CheckPoint photo_CheckPoint = _context.Photo_CheckPoints.Find(ID); var checkPointList = _context.Beacons.ToList(); ViewModel.PhotoCheckPointViewModel data = new ViewModel.PhotoCheckPointViewModel() { CheckPoints = checkPointList, Photo_CheckPoint = photo_CheckPoint }; return(View(data)); }
public IHttpActionResult PostPhoto_Place(Photo_CheckPoint photo_Place) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Photo_CheckPoints.Add(photo_Place); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = photo_Place.ID }, photo_Place)); }
public IHttpActionResult DeletePhoto_Place(int id) { Photo_CheckPoint photo_Place = db.Photo_CheckPoints.Find(id); if (photo_Place == null) { return(NotFound()); } db.Photo_CheckPoints.Remove(photo_Place); db.SaveChanges(); return(Ok(photo_Place)); }
public void SavePhotoCheckPoint(HttpFileCollectionBase images, int checkPointId) { PhotoUtil utilPhoto = new PhotoUtil(); List <Photo_CheckPoint> listCheckPoint = new List <Photo_CheckPoint>(); for (int i = 0; i < images.Count; i++) { string imageEncoded = utilPhoto.EncodeImage(images[i]); Photo_CheckPoint photo_CheckPoint = new Photo_CheckPoint() { CheckPointId = checkPointId, Photo_Code = imageEncoded, Photo_Extension = Path.GetExtension(images[i].FileName), Photo_Path = Path.GetFileNameWithoutExtension(images[i].FileName) }; listCheckPoint.Add(photo_CheckPoint); } _context.Photo_CheckPoints.AddRange(listCheckPoint); _context.SaveChanges(); }
public ActionResult Update(Photo_CheckPoint photo_CheckPoint) { if (!ModelState.IsValid) { return(View("Edit", photo_CheckPoint)); } else { PhotoUtil utilPhoto = new PhotoUtil(); HttpFileCollectionBase image = Request.Files; if (image.Count > 0 && image[0].ContentLength > 0) { photo_CheckPoint.Photo_Code = utilPhoto.EncodeImage(image[0]); photo_CheckPoint.Photo_Extension = Path.GetExtension(image[0].FileName); } _context.Entry(photo_CheckPoint).State = EntityState.Modified; _context.SaveChanges(); } return(RedirectToAction("List", new RouteValueDictionary( new { controller = "Photo_CheckPoint", action = "List", checkPointId = photo_CheckPoint.CheckPointId }))); }