public static MailAddressCollection GetCC(RecommendRequestObj obj) { try { using (var context = new SalesReturndbEntities()) { MailAddressCollection ccEmail = new MailAddressCollection(); RequestDetailObj_Render data1 = CommonDAL.GetRequestDetails(obj.Request_Id, obj.CurrentStatus_Id, obj.FutureStatus_Id); var RegionalHead = context.SP_LFGDetails(data1.EmployeeCode).FirstOrDefault(); if (RegionalHead != null) { if (!(RegionalHead.Regional_Head.ToUpper().Trim().Equals("NA") || RegionalHead.Regional_Head.Trim().Equals(string.Empty))) { var RegionalHeadData = context.SP_LFGDetails(RegionalHead.Regional_Head).FirstOrDefault(); ccEmail.Add(RegionalHeadData.email_id); } if (!(RegionalHead.segmentHead.ToUpper().Trim().Equals("NA") || RegionalHead.segmentHead.Trim().Equals(string.Empty))) { var SegmentHeadData = context.SP_LFGDetails(RegionalHead.segmentHead).FirstOrDefault(); ccEmail.Add(SegmentHeadData.email_id); } ccEmail.Add(RegionalHead.email_id);//Email Id of Requestor } var DepotMaster = context.SP_GetDepotList().Where(x => x.DepotId == data1.DepotId).FirstOrDefault(); var AssintoEmp = context.TblEmployeeMasters.Where(x => x.IsActive == true && x.DepotName == DepotMaster.DepotName).FirstOrDefault(); var ComplaintHandler = context.SP_LFGDetails(AssintoEmp.ComplaintHandler).FirstOrDefault(); var CompalintManager = context.SP_LFGDetails(AssintoEmp.ComplaintManager).FirstOrDefault(); ccEmail.Add(ComplaintHandler.email_id); ccEmail.Add(CompalintManager.email_id); var LogistickHead = context.SP_LFGDetails(AssintoEmp.LogisticsHead).FirstOrDefault(); ccEmail.Add(LogistickHead.email_id); if (RegionalHead != null) { if (!(RegionalHead.VPHead.ToUpper().Trim().Equals("NA") || RegionalHead.VPHead.Trim().Equals(string.Empty))) { var vphead = context.sp_GetuserDetailsFromLFG(RegionalHead.VPHead).FirstOrDefault(); ccEmail.Add(vphead.email_id); } if (!(RegionalHead.President_Code.ToUpper().Trim().Equals("NA") || RegionalHead.President_Code.Trim().Equals(string.Empty))) { var President_Code = context.sp_GetuserDetailsFromLFG(RegionalHead.President_Code).FirstOrDefault(); ccEmail.Add(President_Code.email_id); } } var depot = context.SP_LFGDetails(AssintoEmp.Depotcode).FirstOrDefault(); ccEmail.Add(depot.email_id); var cso = context.SP_LFGDetails(AssintoEmp.CSO).FirstOrDefault(); ccEmail.Add(cso.email_id); return(ccEmail); } } catch (Exception ex) { throw ex; } }