private static RequesterDTO CreateRequesterDTO(EmailMessage messageToProcess) { var requesterDto = new RequesterDTO { Email = messageToProcess.FromAddress, SourceType = RequesterSourceTypeEnum.Mail }; if (string.IsNullOrEmpty(messageToProcess.FromDisplayName)) { return(requesterDto); } var name = messageToProcess.FromDisplayName.Split(new[] { ' ' }, 2); switch (name.Length) { case 1: requesterDto.FirstName = string.IsNullOrEmpty(name[0]) ? messageToProcess.FromAddress : name[0]; break; case 2: requesterDto.FirstName = name[0]; requesterDto.LastName = name[1]; break; } return(requesterDto); }
public static UserLite Create(RequesterDTO requesterDto) { var userLite = new UserLite(); Mapper.DynamicMap(requesterDto, userLite); userLite.UserType = UserType.Requester; return(userLite); }
public bool CanChangeEmailTo(string email) { RequesterDTO dto = FindByEmail(email); if (dto == null) { return(true); } return(dto.ID == Logged.ID); }
public static Requester FindByEmail(string email) { log.DebugFormat("Find user by email '{0}'", email); var service = ServiceManager.GetService <RequesterService>(); RequesterDTO dto = service.FindByEmail(email); if (dto == null) { return(null); } return(DataConverter <Request> .Convert(dto, new Requester()) as Requester); }
public ActionResult SubmitRequest(RequestDetailsVM requestDetailsVM) { bool IsRequestSubmitted = true; RequestBS requestBSObj = new RequestBS(); RequestParamsDTO requestDTO = new RequestParamsDTO { IDSSPEntity = requestDetailsVM.IDSSPEntity, SASDDEntity = requestDetailsVM.SASDDEntity, HPALMEntity = requestDetailsVM.HPALMEntity, MKSIntegrity = requestDetailsVM.MKSIntegrity, DMCCEntity = requestDetailsVM.DMCCEntity, IDSDropZoneEntity = requestDetailsVM.IDSDropZoneEntity, }; UserDTO requesterUserDTO = new UserDTO { EmailId = requestDetailsVM.UserEmailId, FirstName = requestDetailsVM.FirstName, LastName = requestDetailsVM.LastName, NTId = requestDetailsVM.NTId, UserId = requestDetailsVM.UserId }; RequesterDTO requesterDTO = new RequesterDTO { User = requesterUserDTO }; UserDTO managerUserDTO = new UserDTO { EmailId = requestDetailsVM.ManagerEmailId, FirstName = requestDetailsVM.ManagerFirstName, LastName = requestDetailsVM.ManagerLastName, NTId = requestDetailsVM.ManagerNetworkId, UserId = requestDetailsVM.ManagerWWID }; ManagerDTO managerDTO = new ManagerDTO { User = managerUserDTO }; RequestUserDetailsDTO requestUserDetailsDTO = new RequestUserDetailsDTO { ApplicationId = requestDetailsVM.ApplicationId, ManagerDTO = managerDTO, RequesterDTO = requesterDTO, RequestCreatedDt = DateTime.Now.ToString(), RequestParams = requestDTO, RequestStateId = requestDetailsVM.RequestStateId, StatusInd = "1" }; int requestId = requestBSObj.SubmitRequestBS(requestUserDetailsDTO); if (requestId != 0) { try { MailMessage mail = new MailMessage(); mail.From = new MailAddress(requestDetailsVM.UserEmailId); mail.To.Add(requestDetailsVM.ManagerEmailId); SmtpClient client = new SmtpClient(); client.Port = 25; client.DeliveryMethod = SmtpDeliveryMethod.Network; client.Credentials = new System.Net.NetworkCredential(requestDetailsVM.NTId, requestDetailsVM.Password); client.Host = "smtp.na.jnj.com"; mail.Subject = "Request Id:" + requestId + "-Approval Request For" + requestDetailsVM.UserName; mail.IsBodyHtml = true; // StringWriter writer = new StringWriter(); // HtmlTextWriter html = new HtmlTextWriter(writer); // //html.RenderBeginTag(HtmlTextWriterTag.H1); // //html.WriteEncodedText("Heading Here"); // //html.RenderEndTag(); // html.WriteEncodedText(String.Format("Dear {0} {1}", requestDetailsVM.ManagerName,',')); // html.WriteBreak(); // html.RenderBeginTag(HtmlTextWriterTag.P); // html.WriteEncodedText("Please visit below link to make the approval"); // html.RenderEndTag(); //// html.WriteBreak(); // html.AddAttribute(HtmlTextWriterAttribute.Href, "http://WIN-HRCH1I5K9R1.wks.jnj.com/Approval/GetRequest/" + requestId); // html.RenderBeginTag(HtmlTextWriterTag.A); // html.WriteEncodedText("Approval Link"); // html.RenderEndTag(); //// html.WriteBreak(); // html.RenderBeginTag(HtmlTextWriterTag.P); // html.WriteEncodedText("Thanks and Regards,"); //// html.RenderEndTag(); // html.WriteBreak(); //// html.RenderBeginTag(HtmlTextWriterTag.P); // html.WriteEncodedText("IDS Support Team"); // html.RenderEndTag(); // // html.WriteBreak(); // html.Flush(); // string htmlString = writer.ToString(); ViewData.Add("RequestId", requestId); ViewData.Add(new KeyValuePair <string, object>("Approver", requestDetailsVM.ManagerName)); ViewData.Add(new KeyValuePair <string, object>("Requester", requestDetailsVM.UserName)); string htmlEmailBody = HTMLHelper.ToHtml("ApprovalEmailTemplate", ViewData, this.ControllerContext).ToString(); mail.Body = htmlEmailBody.ToString(); client.Send(mail); } catch (Exception ex) { IsRequestSubmitted = false; return(Json(IsRequestSubmitted, JsonRequestBehavior.AllowGet)); } } return(Json(IsRequestSubmitted, JsonRequestBehavior.AllowGet)); }