public JsonResult Create(EmailView emailview, string userName) { Domain.Email newEmail; UpdateModel(emailview); var email = map.Map <EmailView, Domain.Email>(emailview); if (emailview.attachment != null) { email.attachment = Server.HtmlDecode(emailview.attachment); email.attachmentContentType = System.Net.Mime.MediaTypeNames.Text.Html; } if (emailview.woid.HasValue) { newEmail = serv.Create(email, userName, emailview.woid); } else { newEmail = serv.Create(email, userName); } return(Json(new { sNewRef = _getTabRef(newEmail), sNewLabel = _getTabLabel(newEmail), iNewID = newEmail.ID, jobSuccess = true }, JsonRequestBehavior.AllowGet)); }
public async Task <JsonResult> Create(EmailView emailview, string userName) { Email newEmail; if (await TryUpdateModelAsync(emailview)) { var email = map.Map <EmailView, Email>(emailview); if (emailview.attachment != null) { email.attachment = HttpUtility.UrlDecode(emailview.attachment); email.attachmentContentType = MediaTypeNames.Text.Html; } if (emailview.woid.HasValue) { newEmail = serv.Create(email, userName, emailview.woid); } else { newEmail = serv.Create(email, userName); } return(Json(new { sNewRef = _getTabRef(newEmail), sNewLabel = _getTabLabel(newEmail), iNewID = newEmail.ID, jobSuccess = true })); } else { return(Json(new { jobSuccess = false })); } }
public ActionResult Index() { var model = _emailService.Create("*****@*****.**", "*****@*****.**", "The Spelling Of Your Name", "Your name is spelled wrong..."); model.DateTime = _dateTimeService.Date; return(View(model)); }
public async Task <IHttpActionResult> Createemail() { ResponseDataDTO <email> response = new ResponseDataDTO <email>(); try { var path = Path.GetTempPath(); if (!Request.Content.IsMimeMultipartContent("form-data")) { throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.UnsupportedMediaType)); } MultipartFormDataStreamProvider streamProvider = new MultipartFormDataStreamProvider(path); await Request.Content.ReadAsMultipartAsync(streamProvider); // get data from formdata EmailCreateViewModel emailCreateViewModel = new EmailCreateViewModel { ema_username = Convert.ToString(streamProvider.FormData["ema_username"]), ema_password = Convert.ToString(streamProvider.FormData["ema_password"]), ema_api = Convert.ToString(streamProvider.FormData["ema_api"]), ema_pop_or_imap_server = Convert.ToString(streamProvider.FormData["ema_pop_or_imap_server"]), ema_smtp_server = Convert.ToString(streamProvider.FormData["ema_smtp_server"]), ema_note = Convert.ToString(streamProvider.FormData["ema_note"]), company_id = Convert.ToInt32(streamProvider.FormData["company_id"]), ema_pop_or_imap_port = Convert.ToInt32(streamProvider.FormData["ema_pop_or_imap_port"]), ema_smtp_port = Convert.ToInt32(streamProvider.FormData["ema_smtp_port"]), }; // mapping view model to entity var createdemail = _mapper.Map <email>(emailCreateViewModel); // save new email _emailservice.Create(createdemail); // return response response.Code = HttpCode.OK; response.Message = MessageResponse.SUCCESS; response.Data = createdemail; return(Ok(response)); } catch (Exception ex) { response.Code = HttpCode.INTERNAL_SERVER_ERROR; response.Message = ex.Message; response.Data = null; Console.WriteLine(ex.ToString()); return(Ok(response)); } }
public IHttpActionResult Post([FromBody] CreateEmailViewModel model) { if (model == null) { return(BadRequest()); } Email email = new Email { Address = model.Address }; emailService.Create(email); return(Ok()); }
public async Task <IActionResult> Post( [HttpTrigger(AuthorizationLevel.Function, "post", Route = "queries")] HttpRequest req, ILogger log) { log.LogInformation("C# HTTP trigger function processed a request."); if (req == null) { return(new NotFoundObjectResult("Null HttpRequest")); } string requestBody = await _readerService.ReadToEndAsync(req.Body); if (string.IsNullOrEmpty(requestBody)) { return(new BadRequestObjectResult("Could not find Start Date or End date")); } var data = _jsonConverter.DeserializeObject <VehicleQueryRequest>(requestBody); if (data == null) { return(new BadRequestObjectResult("VehicleQueryrequest is null after deserialization")); } try { var result = await _vehicleQueryService.GetByDate(data.StartDate, data.EndDate); //Send Email var msg = _emailService.Create(result); if (msg == null) { log.LogWarning("Error creating Email"); } var response = await _emailService.Send(msg); log.LogInformation($"Output Response: {response.Success} - {response.Message}. Number of Queries: {result.NumberOfQueries}"); return(new OkObjectResult(result)); } catch (Exception e) { log.LogInformation($"Exception occured. {e.Message}"); throw e; } }
public FluentRecordBase AddEmail( int?status = null, DateTime?datecreated = null, DateTime?dateupdated = null, string attachment = null, string attachmentType = null ) { // // DEPENDENCIES _servEM = container.Resolve <IEmailService>(); // // ARRANGE _email = (Email)Records.email.Clone(); if (datecreated != null) { _email.datecreated = (DateTime)datecreated; } if (dateupdated != null) { _email.dateupdated = (DateTime)dateupdated; } if (status != null) { _email.statusID = (int)status; } if (attachment != null) { _email.attachment = attachment; } if (attachmentType != null) { _email.attachment = attachmentType; } // // ACT _servEM.Create(_email, _user); return(this); }
public virtual async void TestDelete() { var builder = new WebHostBuilder() .UseEnvironment("Production") .UseStartup <TestStartup>(); TestServer testServer = new TestServer(builder); var client = new ApiClient(testServer.CreateClient()); ApplicationDbContext context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext; IEmailService service = testServer.Host.Services.GetService(typeof(IEmailService)) as IEmailService; var model = new ApiEmailServerRequestModel(); model.SetProperties(1, DateTime.Parse("1/1/1988 12:00:00 AM"), "B"); CreateResponse <ApiEmailServerResponseModel> createdResponse = await service.Create(model); createdResponse.Success.Should().BeTrue(); ActionResponse deleteResult = await client.EmailDeleteAsync(2); deleteResult.Success.Should().BeTrue(); ApiEmailServerResponseModel verifyResponse = await service.Get(2); verifyResponse.Should().BeNull(); }
public async Task <IActionResult> CreateAsync(EmailDto emailDto) { await emailService.Create(emailDto); return(StatusCode(201)); }