public int AddPartner(PartnerDTO dto) { int id = 0; try { log.Debug(PartnerDTO.FormatPartnerDTO(dto)); R_Partner t = PartnerDTO.ConvertDTOtoEntity(dto); // add id = Repository.AddPartner(t); dto.PartnerId = id; log.Debug("result: 'success', id: " + id); } catch (System.Exception e) { // error log.Error(e.ToString()); throw; } return(id); }
//[ValidateAntiForgeryToken] public IActionResult AddPost(PartnerViewModel partnerViewModels) { var partnerList = _partner.GetPartners(); ViewBag.Partners = partnerList; if (partnerViewModels.Id == 0) { ModelState.Remove("Id"); if (ModelState.IsValid) { var partner = _mapper.Map <Partner>(partnerViewModels); _partner.AddPartner(partner); _toastNotification.AddSuccessToastMessage("تم بيانات الشريك بنجاح"); return(RedirectToAction(nameof(Index))); } return(View(nameof(Index), partnerViewModels)); } else { if (ModelState.IsValid) { var partner = _mapper.Map <Partner>(partnerViewModels); _partner.UpdatePartner(partnerViewModels.Id, partner); _toastNotification.AddSuccessToastMessage("تم تعديل بيانات الشريك بنجاح"); return(RedirectToAction(nameof(Index))); } return(View(nameof(Index), partnerViewModels)); } }
public async Task CreatePartner(PartnerRequest partnerRequest) { // Convert the partner request to a new partner var partner = partnerRequest.ToPartner(); // Add the partner record var newPartner = await partnerRepository.AddPartner(partner).ConfigureAwait(false); // Make the creator of the partner request a registered user for the partner var partnerUser = new PartnerUser { PartnerId = newPartner.Id, UserId = partnerRequest.CreatedByUserId, CreatedByUserId = partnerRequest.CreatedByUserId, LastUpdatedByUserId = partnerRequest.LastUpdatedByUserId, }; await partnerUserRepository.AddPartnerUser(partnerUser).ConfigureAwait(false); // Notify user when their request has been approved and what to do next // Need a template for this //var email = new Email //{ // Message = $"From Email: {partnerRequest.PrimaryEmail}\nFrom Name:{partnerRequest.Name}\nMessage:\n{partnerRequest.Notes}", // Subject = "Partner Request" //}; //email.Addresses.Add(new EmailAddress { Name = Constants.TrashMobEmailName, Email = Constants.TrashMobEmailAddress }); //await emailManager.SendSystemEmail(email, CancellationToken.None).ConfigureAwait(false); }