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; } }
private PartnerDTO Update(PartnerViewModel viewModel) { try { log.Debug(PartnerViewModel.FormatPartnerViewModel(viewModel)); // get log.Debug("_partnerService.GetPartner - partnerId: " + viewModel.PartnerId + " "); var existingPartner = _partnerService.GetPartner(viewModel.PartnerId); log.Debug("_partnerService.GetPartner - " + PartnerDTO.FormatPartnerDTO(existingPartner)); if (existingPartner != null) { // copy values viewModel.UpdateDTO(existingPartner, null); //RequestContext.Principal.Identity.GetUserId()); // update log.Debug("_partnerService.UpdatePartner - " + PartnerDTO.FormatPartnerDTO(existingPartner)); _partnerService.UpdatePartner(existingPartner); log.Debug("result: 'success'"); } else { log.Error("existingPartner: null, PartnerId: " + viewModel.PartnerId); } return(existingPartner); } catch (Exception e) { // error log.Error(e.ToString()); throw; } }