public virtual async Task<IMessageDeliveryResult> Send(byte[] fileContent, string filetype, SendModel sendModel) { var recipient = new RecipientById(IdentificationType.DigipostAddress, sendModel.DigipostAddress); var primaryDocument = new Document(sendModel.Subject, filetype, fileContent) { SensitivityLevel = sendModel.SensitivityOption, AuthenticationLevel = sendModel.AuthenticationOption }; if (sendModel.SmsAfterHour) primaryDocument.SmsNotification = new SmsNotification(int.Parse(sendModel.SmsAfterHours)); var m = new Message(recipient, primaryDocument); IMessageDeliveryResult result = null; try { result = await GetClient().SendMessageAsync(m); } catch (ClientResponseException e) { var errorMessage = e.Error; Logger.Error("> Error." + errorMessage); throw; } return result; }
public ActionResult Index(SendModel sendModel) { var isEmptyModel = sendModel == null || string.IsNullOrEmpty(sendModel.DigipostAddress); if (isEmptyModel) { sendModel = GetSendModelFromSession(); } return View("Index", sendModel); }
private SendModel GetSendModelFromSession() { var searchDetails = SessionManager.GetFromSession<SearchDetails>(HttpContext, SessionConstants.PersonModel); SendModel sendModel = new SendModel(); if (searchDetails != null) { sendModel = Converter.SearchDetailsToSendModel(searchDetails); } SessionManager.RemoveFromSession(HttpContext, SessionConstants.PersonModel); return sendModel; }
public async Task<ActionResult> Send(SendModel sendModel) { byte[] fileContent = null; var fileType = ""; var hasError = IsValidFileContent(ref fileContent, ref fileType); if (hasError) { return View("Index", sendModel); } var result = await _digipostService.Send(fileContent, fileType, sendModel); return View("SendStatus", result); }
public static SendModel SearchDetailsToSendModel(SearchDetails searchDetails) { var sendModel = new SendModel(); if (searchDetails.SearchDetailsAddress != null) { sendModel.AdditionalAddressLine = searchDetails.SearchDetailsAddress.AdditionalAddressLine; sendModel.City = searchDetails.SearchDetailsAddress.City; sendModel.HouseLetter = searchDetails.SearchDetailsAddress.HouseLetter; sendModel.HouseNumber = searchDetails.SearchDetailsAddress.HouseNumber; sendModel.Street = searchDetails.SearchDetailsAddress.Street; sendModel.ZipCode = searchDetails.SearchDetailsAddress.ZipCode; } sendModel.DigipostAddress = searchDetails.DigipostAddress; sendModel.FirstName = searchDetails.FirstName; sendModel.MiddleName = searchDetails.MiddleName; sendModel.LastName = searchDetails.LastName; sendModel.MobileNumber = searchDetails.MobileNumber; sendModel.OrganizationName = searchDetails.OrganizationName; return sendModel; }