public IHttpActionResult Create(MerchantPostRep resource)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.BadRequest(this.ModelState));
            }

            try
            {
                var @event = new MerchantCreateEvent
                {
                    IdUser       = resource.IdUser,
                    Name         = resource.Name,
                    BusinessName = resource.BusinessName,
                    TaxId        = resource.TaxId,
                    ContactName  = resource.ContactName,
                    ContactPhone = resource.ContactPhone,
                    CreatedBy    = this.Identity
                };

                this._merchantService.Add(@event);

                return(this.CreatedAtRoute(MerchantResourceNames.Routes.GetById, new { id = @event.Id }, resource));
            }
            catch (Exception ex)
            {
                return(this.InternalServerError(ex));
            }
        }
        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));
            }
        }