public HttpResponseMessage UpdateMarkers([FromBody] MarkersInformation model) { //查询坐标是否存在 var markers = MarkersDapper.Query("select * from markersInformation where id=@id", new { id = model.Id }).FirstOrDefault(); if (markers == null) { return(Request.CreateResponse(HttpStatusCode.OK, new { status = "error" }, Configuration.Formatters.JsonFormatter)); } model.Images = model.Images.Trim(','); var imgs = model.Images.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < imgs.Length; i++) { var imga = imgs[i].Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries); imgs[i] = "/" + imga[imga.Length - 2] + "/" + imga[imga.Length - 1]; } model.Images = string.Join(",", imgs); if (imgs.Length > 0) { model.CoverImage = imgs[0]; } //如果时异常状态,更改后偶则为审核状态 if (markers.Status == 1) { model.Status = 2; } MarkersDapper.Update(model); HttpResponseMessage result = Request.CreateResponse(HttpStatusCode.OK, new { status = "OK" }, Configuration.Formatters.JsonFormatter); return(result); }
public HttpResponseMessage DelMarkers([FromBody] MarkersInformation model) { var count = MarkersDapper.Update("update markersInformation set isdel=1 where id=@Id", model); HttpResponseMessage result = Request.CreateResponse(HttpStatusCode.OK, new { status = "OK", data = count == 1 }, Configuration.Formatters.JsonFormatter); return(result); }
[Route("post/Markers")]//68295134 public HttpResponseMessage Post([FromBody] MarkersInformation model) { model.Images = model.Images.TrimEnd(','); var imgs = model.Images.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); if (imgs.Length > 0) { model.CoverImage = imgs[0]; } model.Id = Guid.NewGuid().ToString(); MarkersDapper.Add(model); HttpResponseMessage result = Request.CreateResponse(HttpStatusCode.OK, new { status = "OK" }, Configuration.Formatters.JsonFormatter); return(result); }