Пример #1
0
        public void Update(MerchantUpdateEvent @event)
        {
            var entity = this._merchantEntityService.Get(@event.Id);

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

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

            this._merchantEntityService.Edit(entity);
            this._merchantEntityService.Save();
        }
Пример #2
0
        public IHttpActionResult Update(string id, MerchantPostRep resource)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.BadRequest(this.ModelState));
            }

            try
            {
                var @event = new MerchantUpdateEvent
                {
                    Id           = Guid.Parse(id),
                    Name         = resource.Name,
                    BusinessName = resource.BusinessName,
                    Active       = resource.Active,
                    ContactName  = resource.ContactName,
                    ContactPhone = resource.ContactPhone,

                    ModifiedBy = this.Identity,
                };

                this._merchantService.Update(@event);

                return(this.CreatedAtRoute(MerchantResourceNames.Routes.GetById, new { id = @event.Id }, resource));
            }
            catch (FormatException)
            {
                return(this.BadRequest());
            }
            catch (ObjectNotFoundException)
            {
                return(this.NotFound());
            }
            catch (Exception ex)
            {
                return(this.InternalServerError(ex));
            }
        }