public async Task <ActionResult> RequestDetails(RequestDetailsVM model)
        {
            if (ModelState.IsValid)
            {
            }

            await model.PopulateLists();

            return(View(model));
        }
        public async Task <ActionResult> RequestDetails(int ID)
        {
            RequestDetailsVM model = new RequestDetailsVM();

            model.RequestID = ID;
            await model.PopulateModel();

            await model.PopulateLists();

            ViewData.Model = model;
            return(View());
        }
        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));
        }