private void Button_Clicked(object sender, EventArgs e) { var s = sender as Button; CongestionModel model = BindingContext as CongestionModel; //SendMaps?.Invoke(model, e); AppConstants.lat = model.Latitude; AppConstants.lang = model.Longitude; SendMaps?.Invoke(model, e); }
public IHttpActionResult PutCongestion(CongestionModel congestionModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { var congestionsExist = db.Congestions.FirstOrDefault(w => w.Id == congestionModel.Id); if (congestionsExist != null) { congestionsExist.Location = Common.CreatePoint(congestionModel.Latitude, congestionModel.Longitude); congestionsExist.Description = congestionModel.Description; congestionsExist.Name = congestionModel.Name; db.SaveChanges(); Common.Push(congestionModel.Longitude, congestionModel.Latitude, 10000, "Traffic jam near Jayamahal due to " + congestionModel.Name, congestionsExist.Id, 1); } else { var congestion = new Congestion(); congestion.Id = Guid.NewGuid(); congestion.IsActive = true; congestion.CongestionTypeId = Guid.Parse("108853b3-4cf0-4141-91d7-5b791e2981dc"); congestion.CreatedDate = DateTime.UtcNow; congestion.Location = Common.CreatePoint(congestionModel.Latitude, congestionModel.Longitude); congestion.Description = congestionModel.Description; congestion.Name = congestionModel.Name; congestion.OrgUserId = Guid.Parse("111faecf-3e24-4e15-9a96-aa924855205b"); congestion.Contact = congestionModel.Contact; db.Congestions.Add(congestion); db.SaveChanges(); Common.Push(congestionModel.Longitude, congestionModel.Latitude, 10000, "Traffic jam near Jayamahal due to " + congestionModel.Name, congestion.Id, 1); } db.SaveChanges(); return(Ok()); } catch (Exception ex) { return(BadRequest(ex.Message)); } }