public async Task <IActionResult> AddNewProject(ProjectModel projectModel)
        {
            if ((projectModel.startDate < DateTime.Now) || (projectModel.EndDate < DateTime.Now))
            {
                return(RedirectToAction(nameof(AddNewProject), new { currentContext = true }));
            }

            if (projectModel.startDate >= projectModel.EndDate)
            {
                return(RedirectToAction(nameof(AddNewProject), new { invalid = true }));
            }

            if (ModelState.IsValid)
            {
                int id = await _projectRepository.AddNewProject(projectModel);

                if (id > 0)
                {
                    return(RedirectToAction(nameof(AddNewProject), new { isSuccess = true, projectId = id }));
                }
            }
            ViewBag.Customers      = new SelectList(await _repo3.GetCustomers(), "Id", "Name");
            ViewBag.ProjectManager = new SelectList(await _projectManagerRepository.GetProjectManager("project manager"), "Id", "Name");
            return(View());
        }
        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));
        }