public async Task <IActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { var user = await _userHelper.GetUserByEmailAsync(model.UserName); if (user == null) { user = _converterHelper.ToNewUserFromRegisterViewModel(model); user.IsActive = false; user.CreationDate = DateTime.UtcNow; user.CanLogin = true; var result = await _userHelper.AddUserAsync(user, model.Password); if (result != IdentityResult.Success) { this.ModelState.AddModelError(string.Empty, "The user could not be created"); return(this.View(model)); } var UserRole = await _userHelper.IsUSerInRoleAsync(user, "Customer"); if (!UserRole) { await _userHelper.AddUserToRoleAsync(user, "Customer"); } var myToken = await _userHelper.GenerateEmailConfirmationTokenAsync(user); var tokenLink = this.Url.Action("ConfirmEmail", "Accounts", new { userId = user.Id, token = myToken, }, protocol: HttpContext.Request.Scheme); _mailHelper.SendEmail(model.UserName, "Email Confirmation", $"<h1>Email Confirmation</h1>" + $"To allow the user, " + $"plase click in this link:</br></br><a href = \"{tokenLink}\">Confirm Email</a>"); this.ViewBag.Message = "The instructions for completing your registration have been sent to your email"; return(View(model)); } this.ModelState.AddModelError(string.Empty, "The user already exists"); } return(this.View(model)); }
public async Task <MahnungVersendenResponse> MahnungVersenden(List <int> orderItemIds, string language, int gewaehlteMahnungAnzahl, string userId) { try { var orderItemsByUser = await sqlDataAccess.GetOrderItemsByUser(orderItemIds.ToArray()); foreach (var itemByUser in orderItemsByUser) { dataBuilder.Reset(); var dataContext = dataBuilder .AddAuftraege(itemByUser.OrderItemIds) .AddBesteller(itemByUser.UserId) .AddUser(userId) .AddSprache(language) .AddValue("RückgabeTermin", DateTime.Today.AddDays(30).ToString("dd.MM.yyyy")) .Create(); switch (gewaehlteMahnungAnzahl) { case 1: // Sennde Mail Vorlage 1 var template1 = parameterHelper.GetSetting <AusleiheErsteMahnung>(); var user = userAccess.GetUser(itemByUser.UserId); template1.To = user.EmailAddress; await mailHelper.SendEmail(bus, template1, dataContext); break; case 2: // Sende Mail Vorlage 2 var template2 = parameterHelper.GetSetting <AusleiheZweiteMahnung>(); var initiatingUser = userAccess.GetUser(userId); template2.To = initiatingUser.EmailAddress; await mailHelper.SendEmail(bus, template2, dataContext); break; default: throw new InvalidEnumArgumentException(); } } await UpdateMahnungInfoForOrderItems(orderItemIds, gewaehlteMahnungAnzahl, userId); return(new MahnungVersendenResponse { Success = true }); } catch (Exception ex) { Log.Error(ex, "Unexptected error while sending Mahnungen"); return(new MahnungVersendenResponse { Success = false, Error = ex.Message }); } }
public async Task <string> CreateCase(BridgesStructuresReport bridgesStructuresReport) { Case crmCase = CreateCrmCaseObject(bridgesStructuresReport); try { StockportGovUK.NetStandard.Gateways.Response.HttpResponse <string> response = await _VerintServiceGateway.CreateCase(crmCase); if (!response.IsSuccessStatusCode) { throw new Exception("Status code not successful"); } Person person = new Person { FirstName = bridgesStructuresReport.FirstName, LastName = bridgesStructuresReport.LastName, Email = bridgesStructuresReport.Email, Phone = bridgesStructuresReport.Phone, }; _mailHelper.SendEmail(person, EMailTemplate.BridgesStructuresReport, response.ResponseContent); return(response.ResponseContent); } catch (Exception ex) { throw new Exception($"CRMService CreateBridgesOrStructuresService an exception has occured while creating the case in verint service", ex); } }
public async Task <string> CreateCase(ParkingEnforcementRequest parkingEnforcementRequest) { var crmCase = CreateCrmCaseObject(parkingEnforcementRequest); try { var response = await _VerintServiceGateway.CreateCase(crmCase); if (!response.IsSuccessStatusCode) { throw new Exception("Status code not successful"); } Person person = new Person { FirstName = parkingEnforcementRequest.FirstName, LastName = parkingEnforcementRequest.LastName, Email = parkingEnforcementRequest.Email, Phone = parkingEnforcementRequest.Phone, CustomerAddress = parkingEnforcementRequest.CustomersAddress }; _mailHelper.SendEmail(person, EMailTemplate.ParkingEnforcementRequest, response.ResponseContent); return(response.ResponseContent); } catch (Exception ex) { throw new Exception($"CRMService CreateParkingEnforcementService an exception has occurred while creating the case in verint service", ex); } }
private async Task SendEmail(ConsumeContext <IDigitalisierungsAuftragErledigt> context) { try { var mailTemplate = parameterHelper.GetSetting <DigitalisierungsAuftragErledigtProblem>(); var messageContext = context.Message; var dataContext = dataBuilder .AddVe(messageContext.ArchiveRecordId) .AddUser(messageContext.OrderUserId) .AddBesteller(messageContext.OrderUserId) .AddAuftraege(new[] { messageContext.OrderItemId }) .Create(); #if DEBUG mailTemplate.To = dataContext.User.EmailAddress; #endif await mailHelper.SendEmail(bus, mailTemplate, dataContext); } catch (Exception ex) { Log.Error(ex, "An exception occurred while sending an EMail"); throw; } }
public async Task <IActionResult> FinishRepair(FinishRepairViewModel model) { if (model == null) { return(View(model)); } var repairShedule = await _repairScheduleRepository.GetRepairScheduleFinishAsync(model.RepairScheduleID); var scheduleDetail = await _scheduleDetailRepository.GetScheduleDetailByIdAsync(model.ScheduleDetailId); var repair = await _repairRepository.GetByIdAsync(model.RepairId); var activeSchedule = await _activeScheduleRepository.GetByIdAsync(scheduleDetail.ActiveSchedule.Id); var repairHistory = _converterHelper.ToRepairHistory(repairShedule, scheduleDetail); var vehicle = await _vehicleRepository.GetUserVehicle(model.VehicleId); var user = await _userHelper.GetUserByIdAsync(vehicle.User.Id); try { await _repairHistoryRepository.CreateAsync(repairHistory); await _repairScheduleRepository.DeleteAsync(repairShedule); await _scheduleDetailRepository.DeleteAsync(scheduleDetail); await _repairRepository.DeleteAsync(repair); await _activeScheduleRepository.DeleteAsync(activeSchedule); return(RedirectToAction("DealershipRepairs")); } catch (Exception ex) { ModelState.AddModelError(string.Empty, ex.InnerException.Message); } if (user == null) { ModelState.AddModelError(string.Empty, "Unable to send email for the user"); } else { _mailHelper.SendEmail(user.UserName, "Repair finished", $"<h1>Your repair information</h1></br><p>Your vehicle {vehicle.LicencePlate} is ready to be picked up at the workshop</p> </br>"); ViewBag.Message = "An email was sent to the user with this information"; } return(View(model)); }
private async Task SendPasswordEmailGebrauchskopie(ConsumeContext <DownloadAssetRequest> context) { try { var manager = parameterHelper.GetSetting <GebrauchskopiePasswort>(); var message = context.Message; var dataContext = dataBuilder .AddVe(message.ArchiveRecordId) .AddUser(message.Recipient) .AddValue("PasswortZipDatei", passwordHelper.GetHashPassword(message.ArchiveRecordId)) .AddValue("IstGebrauchskopieMitEinsichtsbewilligung", message.RetentionCategory == CacheRetentionCategory.UsageCopyEB) .Create(); await mailHelper.SendEmail(bus, manager, dataContext); } catch (Exception ex) { Log.Error(ex, "An exception occurred while sending an EMail"); throw; } }
public void sendMail() { var mailModle = new EmailModel <Message>(); mailModle.Data = new Message { Content = "My message" }; mailModle.To = "*****@*****.**"; mailModle.Subject = "This is test sub"; _mailHelper.SendEmail(mailModle, "Views/Email/Email.cshtml"); }
public async Task <string> CreateCase(DroppedKerbRequest kerbRequest) { var crmCase = kerbRequest .ToCase(_VOFConfiguration, _verintOptions); var streetResult = await _verintServiceGateway.GetStreet(kerbRequest.StreetAddressDroppedKerb.PlaceRef); if (!streetResult.IsSuccessStatusCode) { throw new Exception("DroppedKerbService.CreateCase: GetStreet status code not successful"); } // confirm uses the USRN for the street, // however Verint uses the verint-address-id (Reference) (kerbRequest.StreetAddress.PlaceRef) for streets crmCase.Street.USRN = streetResult.ResponseContent.USRN; try { var response = await _verintServiceGateway.CreateVerintOnlineFormCase(crmCase.ToConfirmIntegrationFormCase(_VOFConfiguration)); if (!response.IsSuccessStatusCode) { throw new Exception("DroppedKerbService.CreateCase: CreateVerintOnlineFormCase status code not successful"); } var person = new Person { FirstName = kerbRequest.FirstName, LastName = kerbRequest.LastName, Email = crmCase.Customer.Email, Phone = crmCase.Customer.Telephone }; if (!string.IsNullOrEmpty(person.Email)) { _mailHelper.SendEmail( person, EMailTemplate.StreetReport, response.ResponseContent.VerintCaseReference, kerbRequest.StreetAddressDroppedKerb); } return(response.ResponseContent.VerintCaseReference); } catch (Exception ex) { throw new Exception($"DroppedKerbService.CreateCase: CRMService CreateDroppedKerbService an exception has occured while creating the case in verint service", ex); } }
private async Task SendMailGebrauchskopieOk(ConsumeContext <IAssetReady> context) { try { var template = parameterHelper.GetSetting <GebrauchskopieZumDownloadBereit>(); var message = context.Message; var dataContext = dataBuilder .AddVe(message.ArchiveRecordId) .AddUser(message.Recipient) .AddValue("PasswortZipDatei", passwordHelper.GetHashPassword(message.ArchiveRecordId)) .AddValue("IstGebrauchskopieÖffentlich", message.RetentionCategory == CacheRetentionCategory.UsageCopyPublic) .AddValue("IstGebrauchskopieEb", message.RetentionCategory == CacheRetentionCategory.UsageCopyEB) .AddValue("IstGebrauchskopieAb", message.RetentionCategory == CacheRetentionCategory.UsageCopyAB) .AddValue("IstGebrauchskopieBarOderAs", message.RetentionCategory == CacheRetentionCategory.UsageCopyBarOrAS) .Create(); await mailHelper.SendEmail(bus, template, dataContext); } catch (Exception ex) { Log.Error(ex, "An exception occurred while sending an EMail"); throw; } }
public async Task <string> CreateCase(AbandonedVehicleReport abandonedVehicleReport) { var crmCase = abandonedVehicleReport .ToCase(_VOFConfiguration, _verintOptions); var streetResult = await _verintServiceGateway.GetStreet(abandonedVehicleReport.StreetAddress.PlaceRef); if (!streetResult.IsSuccessStatusCode) { throw new Exception("AbandonedVehicleService.CreateCase: GetStreet status code not successful"); } // confirm uses the USRN for the street // however Verint uses the verint-address-id (Reference) (abandonedVehicleReport.StreetAddress.PlaceRef) for street crmCase.Street.USRN = streetResult.ResponseContent.USRN; try { var response = await _verintServiceGateway.CreateVerintOnlineFormCase(crmCase.ToConfirmIntegrationFormCase(_VOFConfiguration)); if (!response.IsSuccessStatusCode) { throw new Exception("AbandonedVehicleService.CreateCase: CreateVerintOnlineFormCase status code not successful"); } var person = new Person { FirstName = abandonedVehicleReport.FirstName, LastName = abandonedVehicleReport.LastName, Email = abandonedVehicleReport.Email, Phone = abandonedVehicleReport.Phone }; _mailHelper.SendEmail( person, EMailTemplate.AbandonedVehicleReport, response.ResponseContent.VerintCaseReference, abandonedVehicleReport.StreetAddress); return(response.ResponseContent.VerintCaseReference); } catch (Exception ex) { throw new Exception($"AbandonedVehicleService.CreateCase: CRMService CreateAbandonedVehicleService an exception has occured while creating the case in verint service", ex); } }
private async Task SendDigipoolFailureMail(int orderItemId, string exceptionInfo) { try { var template = parameterHelper.GetSetting <DigipoolAufbereitungFehlgeschlagen>(); var dataContext = dataBuilder .AddAuftraege(new[] { orderItemId }) .AddValue("exceptionMessage", exceptionInfo) .Create(); await mailHelper.SendEmail(bus, template, dataContext); } catch (Exception ex) { Log.Error(ex, "An exception occurred while sending an EMail"); throw; } }
private void SendMail(string userId) { try { var template = parameterHelper.GetSetting <IdentifizierungErfolgreich>(); var dataContext = dataBuilder .AddUser(userId) .Create(); mailHelper.SendEmail(bus, template, dataContext) .ConfigureAwait(false) .GetAwaiter() .GetResult(); } catch (Exception ex) { Log.Error(ex, "An exception occurred while sending an EMail"); throw; } }
public async Task <string> CreateCase(FloodingRequest request) { try { var streetResult = request.DidNotUseMap ? await _streetHelper.GetStreetDetails(request.Reporter.Address) : await _streetHelper.GetStreetUniqueId(request.Map); if (!request.DidNotUseMap) { request.Map = await ConvertLatLng(request.Map); } else { request.Map = new Map { Lng = streetResult.Easting, Lat = streetResult.Northing }; } var floodingLocationConfig = string.IsNullOrEmpty(request.WhereIsTheFlood) ? _verintOptions.Value.FloodingLocations.FirstOrDefault(_ => _.Type.Equals(request.WhatDoYouWantToReport)) : _verintOptions.Value.FloodingLocations.FirstOrDefault(_ => _.Type.Equals(request.WhereIsTheFlood)); var configuration = request.ToConfig(_confirmAttributeFormOptions.Value, _verintOptions.Value); var crmCase = request.ToCase(configuration, streetResult, floodingLocationConfig); var verintRequest = crmCase.ToConfirmFloodingIntegrationFormCase(configuration.ConfirmIntegrationFormOptions); var caseResult = await _verintServiceGateway.CreateVerintOnlineFormCase(verintRequest); _mailHelper.SendEmail(request, caseResult.ResponseContent.VerintCaseReference); return(caseResult.ResponseContent.VerintCaseReference); } catch (Exception ex) { throw new Exception($"FloodingService:: CreateCase, Failed to create case, exception: {ex.Message}"); } }
public async Task <string> CreateCase(ParkingDispensationRequest parkingDispensationRequest) { var description = $@"Reason: {parkingDispensationRequest.PurposeOfDispensation} Start date: {parkingDispensationRequest.DispensationDateStart.ToString("dd/MM/yyyy")} End date: {parkingDispensationRequest.DispensationDateEnd.ToString("dd/MM/yyyy")} Start time: {parkingDispensationRequest.DispensationTimeStart.ToString("HH:mm")} End time: {parkingDispensationRequest.DispensationTimeEnd.ToString("HH:mm")} Vehicle information: {parkingDispensationRequest.VehicleDetails} Further location information: {parkingDispensationRequest.LocationDetails} "; var crmCase = new Case { EventCode = 2002798, EventTitle = "Request for NON enforcement", Description = description, Street = new Street { Reference = parkingDispensationRequest.StreetAddress?.PlaceRef } }; if (!string.IsNullOrEmpty(parkingDispensationRequest.FirstName) && !string.IsNullOrEmpty(parkingDispensationRequest.LastName)) { crmCase.Customer = new Customer { Forename = parkingDispensationRequest.FirstName, Surname = parkingDispensationRequest.LastName, }; if (!string.IsNullOrEmpty(parkingDispensationRequest.Email)) { crmCase.Customer.Email = parkingDispensationRequest.Email; } if (!string.IsNullOrEmpty(parkingDispensationRequest.Phone)) { crmCase.Customer.Telephone = parkingDispensationRequest.Phone; } if (string.IsNullOrEmpty(parkingDispensationRequest.CustomersAddress?.PlaceRef)) { crmCase.Customer.Address = new Address { AddressLine1 = parkingDispensationRequest.CustomersAddress?.AddressLine1, AddressLine2 = parkingDispensationRequest.CustomersAddress?.AddressLine2, AddressLine3 = parkingDispensationRequest.CustomersAddress?.Town, Postcode = parkingDispensationRequest.CustomersAddress?.Postcode, }; } else { crmCase.Customer.Address = new Address { Reference = parkingDispensationRequest.CustomersAddress?.PlaceRef, UPRN = parkingDispensationRequest.CustomersAddress?.PlaceRef }; } } try { var response = await _VerintServiceGateway.CreateCase(crmCase); if (!response.IsSuccessStatusCode) { throw new Exception("Status code not successful"); } Person person = new Person { FirstName = parkingDispensationRequest.FirstName, Email = parkingDispensationRequest.Email, }; _mailHelper.SendEmail(person, EMailTemplate.ParkingDispensationRequest, response.ResponseContent); return(response.ResponseContent); } catch (Exception ex) { throw new Exception($"CRMService CreateCase an exception has occured while creating the case in verint service", ex); } }
public async Task <IActionResult> CreateEmployee(CreateEmployeeViewModel model) { if (ModelState.IsValid) { var user = _converterHelper.ToEmployeeUser(model.UserName, model.User); if (await _userHelper.GetUserByEmailAsync(user.UserName) == null) { user.IsActive = true; user.CanLogin = true; var result = await _userHelper.AddUserAsync(user, model.Password); if (result != IdentityResult.Success) { this.ModelState.AddModelError(string.Empty, "The user could not be created"); return(this.View(model)); } var dealership = await _dealershipRepository.GetByIdAsync(model.DealershipId); var department = await _departmentRepository.GetByIdAsync(model.DepartmentId); var employee = _converterHelper.ToNewEmplyee(dealership, department, user); employee.CreationDate = DateTime.Now; try { employee.IsActive = true; await _employeeRepository.CreateAsync(employee); } catch (Exception ex) { if (ex.InnerException.Message.Contains("duplicate")) { ViewBag.Error = $"There is allready a Employee registered with the name {user.FullName} please insert another"; var dealerships = _dealershipRepository.GetAll(); var departments = _departmentRepository.GetAll(); var modelret = _converterHelper.ToCreateEmployeeVieModel(dealerships, departments); return(View(modelret)); } else { ModelState.AddModelError(string.Empty, ex.InnerException.Message); var dealerships = _dealershipRepository.GetAll(); var departments = _departmentRepository.GetAll(); var modelret = _converterHelper.ToCreateEmployeeVieModel(dealerships, departments); return(View(modelret)); } } await _userHelper.CheckRoleAsync(employee.Role); var userRole = await _userHelper.IsUSerInRoleAsync(user, employee.Role); if (!userRole) { await _userHelper.AddUserToRoleAsync(user, employee.Role); } var myToken = await _userHelper.GenerateEmailConfirmationTokenAsync(user); var tokenLink = this.Url.Action("ConfirmEmail", "Accounts", new { userId = user.Id, token = myToken, }, protocol: HttpContext.Request.Scheme); _mailHelper.SendEmail(user.UserName, "Email Confirmation", $"<h1>Email Confirmation</h1>" + $"To allow the user, " + $"plase click in this link:</br></br><a href = \"{tokenLink}\">Confirm Email</a>" + $"<p>Your password is {model.Password}, you must change it in first login</p>"); this.ViewBag.Message = "The instructions for completing registration have been sent by email for the user"; return(View(model)); } this.ModelState.AddModelError(string.Empty, $"the user {user.UserName} allready exists"); var dealershipsret = _dealershipRepository.GetAll(); var departmentsret = _departmentRepository.GetAll(); var modelreturn = _converterHelper.ToCreateEmployeeVieModel(dealershipsret, departmentsret); return(View(modelreturn)); } var dealershipsstate = _dealershipRepository.GetAll(); var departmentsstate = _departmentRepository.GetAll(); var modelstate = _converterHelper.ToCreateEmployeeVieModel(dealershipsstate, departmentsstate); return(View(modelstate)); }