public IHttpActionResult Create(LocationPostRep resource) { if (!this.ModelState.IsValid) { return(this.BadRequest(this.ModelState)); } try { var @event = new LocationCreateEvent { Name = resource.Name, IdMerchant = resource.IdMerchant, Implement = resource.Implement, Service = resource.Service, Latitude = resource.Latitude, longitude = resource.longitude, CreatedBy = this.Identity }; this._locationService.Add(@event); return(this.CreatedAtRoute(LocationResourceNames.Routes.GetById, new { id = @event.Id }, resource)); } catch (Exception ex) { return(this.InternalServerError(ex)); } }
public IHttpActionResult Update(string id, LocationPostRep resource) { if (!this.ModelState.IsValid) { return(this.BadRequest(this.ModelState)); } try { var @event = new LocationUpdateEvent { Id = Guid.Parse(id), Name = resource.Name, ModifiedBy = this.Identity, }; this._locationService.Update(@event); return(this.CreatedAtRoute(LocationResourceNames.Routes.GetById, new { id = @event.Id }, resource)); } catch (FormatException) { return(this.BadRequest()); } catch (ObjectNotFoundException) { return(this.NotFound()); } catch (Exception ex) { return(this.InternalServerError(ex)); } }