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 void Add(LocationCreateEvent @event) { var entity = new Location(); entity = this.CreateOrUpdate(@event, entity); entity.Id = Guid.NewGuid(); entity.CreatedBy = @event.CreatedBy; entity.CreatedOn = DateTime.Now; this._locationEntityService.Add(entity); this._locationEntityService.Save(); @event.Id = entity.Id; }