Esempio n. 1
0
        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));
            }
        }
Esempio n. 2
0
        public void Update(LocationUpdateEvent @event)
        {
            var entity = this._locationEntityService.Get(@event.Id);

            if (entity == null)
            {
                throw new ObjectNotFoundException();
            }

            entity            = this.CreateOrUpdate(@event, entity);
            entity.ModifiedBy = @event.ModifiedBy;
            entity.ModifiedOn = DateTime.Now;

            this._locationEntityService.Edit(entity);
            this._locationEntityService.Save();
        }
Esempio n. 3
0
 private async void PanicUpdates(Object sender, LocationUpdateEvent e) => await Task.Run(() => this.PanicUpdate?.Invoke(sender, e));