コード例 #1
0
        private PartnerDTO Create(PartnerViewModel viewModel)
        {
            try
            {
                log.Debug(PartnerViewModel.FormatPartnerViewModel(viewModel));

                PartnerDTO partner = new PartnerDTO();

                // copy values
                viewModel.UpdateDTO(partner, null); //RequestContext.Principal.Identity.GetUserId());

                // audit
                partner.CreateBy = null; //RequestContext.Principal.Identity.GetUserId();
                partner.CreateOn = DateTime.UtcNow;

                // add
                log.Debug("_partnerService.AddPartner - " + PartnerDTO.FormatPartnerDTO(partner));

                int id = _partnerService.AddPartner(partner);

                partner.PartnerId = id;

                log.Debug("result: 'success', id: " + id);

                return(partner);
            }
            catch (Exception e)
            {
                // error
                log.Error(e.ToString());

                throw;
            }
        }
コード例 #2
0
        public IHttpActionResult AddPartner([FromBody] Partner partner)
        {
            try
            {
                _partnerService.AddPartner(partner);
            }
            catch (Exception e)
            {
                throw new HttpResponseException(HttpStatusCode.BadRequest);
            }

            return(Ok());
        }