public static dynamic AddNewProject(Mst_Project objnewproject) { CustomResponse objres = new CustomResponse(); try { using (var objcontext = new Db_Zon_Test_techsupportEntities()) { objcontext.Mst_Project.Add(objnewproject); objcontext.SaveChanges(); objres.Message = "Success"; objres.Response = objnewproject; objres.Status = CustomResponseStatus.Successful; return(objres); } } catch (Exception ex) { objres.Message = ex.Message; objres.Response = null; objres.Status = CustomResponseStatus.UnSuccessful; return(objres); } }
public dynamic Put(CreateProjectDTO objupdateProject) { Mst_Project objprojectNew = new Mst_Project { ID = objupdateProject.objProject.ID, Name = objupdateProject.objProject.Name, Description = objupdateProject.objProject.Description, ShortName = objupdateProject.objProject.ShortName, Duration = objupdateProject.objProject.Duration, ClientID = objupdateProject.objProject.ClientID, PManagerID = objupdateProject.objProject.PManagerID, ProposedEndDate = objupdateProject.objProject.ProposedEndDate, SignUpDate = objupdateProject.objProject.SignUpDate, StartDate = objupdateProject.objProject.StartDate, Status = objupdateProject.objProject.Status, CreatedBy = objupdateProject.objProject.CreatedBy, UpdatedBy = objupdateProject.objProject.UpdatedBy }; List <Mst_ProjectUsers> objusers = new List <Mst_ProjectUsers>(); foreach (string user in objupdateProject.Users) { objprojectNew.Mst_ProjectUsers.Add(new Mst_ProjectUsers { UserID = user }); } return(ProjectRepository.UpdateProject(objprojectNew)); }
internal static void ProjectCreationMail(Mst_Project objproject, string ToMail) { MailMessage Msg = new MailMessage(); Msg.From = new MailAddress(ConfigurationManager.AppSettings["Email"]); Msg.Subject = "Zon Ticketing System - New Ticket Information"; StreamReader reader = new StreamReader(HttpContext.Current.Server.MapPath("/Email Templates/EmailTemplate.html"));//EmailTemplate1.html string readFile = reader.ReadToEnd(); string StrContent = ""; StrContent = readFile; StringBuilder sb = new StringBuilder(); sb.Append("<table width=100%>"); sb.Append("<tr><td>Project Name<center></td><td>" + objproject.Name + "</td></tr>"); sb.Append("<tr><td>Project Description<center></td><td><center>" + objproject.Description + "</td></tr>"); sb.Append("<tr><td>Project Manager<center></td><td><center>" + UserRepository.GetFnamebyUid(objproject.PManagerID) + "</td></tr>"); sb.Append("<tr><td>Client <center></td><td><center>" + UserRepository.GetFnamebyUid(objproject.ClientID) + "</td></tr>"); sb.Append("<tr><td>Project Manager<center></td><td><center>" + UserRepository.GetFnamebyUid(objproject.CreatedBy) + "</td></tr>"); sb.Append("<tr><td>Project Manager<center></td><td><center>" + objproject.StartDate + "</td></tr>"); sb.Append("<tr><td>Project Manager<center></td><td><center>" + objproject.ProposedEndDate + "</td></tr>"); sb.Append("</table>"); StrContent = StrContent.Replace("$$TemplateBody$$", "<span> A New Task is created in the Project <b>" + objproject.Name + "</b> by <b>" + UserRepository.GetFnamebyUid(objproject.CreatedBy) + "</b>.\n Please find the Details below. </span></br><div>" + sb.ToString()); Msg.To.Add(ToMail.ToString()); StrContent = StrContent.Replace("$$User$$", ToMail.ToString()); Msg.Body = StrContent.ToString(); Msg.IsBodyHtml = true; // your remote SMTP server IP. SmtpClient smtp = new SmtpClient(); smtp.Host = ConfigurationManager.AppSettings["MailServer"]; System.Net.NetworkCredential NetworkCred = new System.Net.NetworkCredential(); NetworkCred.UserName = ConfigurationManager.AppSettings["UserName"]; NetworkCred.Password = ConfigurationManager.AppSettings["Password"]; smtp.UseDefaultCredentials = true; smtp.Credentials = NetworkCred; object mailstate = Msg; smtp.SendCompleted += new SendCompletedEventHandler(smtpClient_SendCompleted); smtp.Port = int.Parse(ConfigurationManager.AppSettings["MailPort"]); smtp.EnableSsl = Convert.ToBoolean(ConfigurationManager.AppSettings["IsSSLEnabled"].ToString()); smtp.SendAsync(Msg, mailstate); }
public dynamic Post(CreateProjectDTO objcreateProject) { Mst_Project objprojectNew = new Mst_Project { Name = objcreateProject.objProject.Name, Description = objcreateProject.objProject.Description, ShortName = objcreateProject.objProject.ShortName, Duration = objcreateProject.objProject.Duration, ClientID = objcreateProject.objProject.ClientID, PManagerID = objcreateProject.objProject.PManagerID, ProposedEndDate = objcreateProject.objProject.ProposedEndDate, SignUpDate = objcreateProject.objProject.SignUpDate, StartDate = objcreateProject.objProject.StartDate, Status = objcreateProject.objProject.Status, CreatedBy = objcreateProject.objProject.CreatedBy }; List <Mst_ProjectUsers> objusers = new List <Mst_ProjectUsers>(); foreach (string user in objcreateProject.Users) { objprojectNew.Mst_ProjectUsers.Add(new Mst_ProjectUsers { UserID = user }); } List <string> ObjToAddresses = new List <string>(); List <string> ObjFilteredToAddresses = new List <string>(); ObjToAddresses.Add(objcreateProject.objProject.CreatedBy); ObjToAddresses.Add(objcreateProject.objProject.ClientID); ObjToAddresses.Add(objcreateProject.objProject.PManagerID); // ObjToAddresses.AddRange(ProjectRepository.GetProjectUsers(objtaskdto.ProjectID)); ObjFilteredToAddresses = ObjToAddresses.Distinct().ToList(); ObjFilteredToAddresses = UserRepository.GetEmailAddressesByUserIds(ObjFilteredToAddresses); foreach (var toMail in ObjFilteredToAddresses) { MailSender.ProjectCreationMail(objprojectNew, toMail); } return(ProjectRepository.AddNewProject(objprojectNew)); }
public static dynamic UpdateProject(Mst_Project objupdateproject) { CustomResponse objres = new CustomResponse(); try { using (var objcontext = new Db_Zon_Test_techsupportEntities()) { int pid = objupdateproject.ID; Mst_Project objdbproject = objcontext.Mst_Project.Where(x => x.ID == pid).FirstOrDefault(); objdbproject.Name = objupdateproject.Name; objdbproject.Description = objupdateproject.Description; objdbproject.PManagerID = objupdateproject.PManagerID; objdbproject.ClientID = objupdateproject.ClientID; objdbproject.SignUpDate = objupdateproject.SignUpDate; objdbproject.StartDate = objupdateproject.StartDate; objdbproject.Duration = objupdateproject.Duration; objdbproject.ShortName = objupdateproject.ShortName; objdbproject.ProposedEndDate = objupdateproject.ProposedEndDate; for (int i = 0; i < objdbproject.Mst_ProjectUsers.Count(); i++) { objdbproject.Mst_ProjectUsers.ElementAt(i).Status = false; } objdbproject.Mst_ProjectUsers = objupdateproject.Mst_ProjectUsers; objcontext.SaveChanges(); objres.Message = "Success"; objres.Response = objdbproject; objres.Status = CustomResponseStatus.Successful; return(objres); } } catch (Exception ex) { objres.Message = ex.Message; objres.Response = null; objres.Status = CustomResponseStatus.UnSuccessful; return(objres); } }
// get particular project detail public static List <string> GetProjectUsers(int projectid) { CustomResponse objres = new CustomResponse(); try { List <string> objUserIds = new List <string>(); using (var objcontext = new Db_Zon_Test_techsupportEntities()) { // Add ProjectManager and Client Info Mst_Project objproject = objcontext.Mst_Project.Where(x => x.ID == projectid).FirstOrDefault(); objUserIds.Add(objproject.PManagerID); objUserIds.Add(objproject.ClientID); // Add ProjectUsers info objUserIds.AddRange(objcontext.Mst_ProjectUsers.Where(x => x.ProjectID == projectid).Select(x => x.UserID).ToList()); return(objUserIds); } } catch (Exception ex) { return(null); } }