public ActionResult Add(CreateProjectVM model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    Project project = new Project { ID = model.ID };

                    project = repo.GetProject(model.Name, UserID);
                    if ((project != null) && (project.ID != model.ID))
                        return Json(new { Status = "Error", Message = "Project name exists" });

                    if (project == null)
                    {
                        if (model.ID > 0)
                            project = repo.GetProject(model.ID);
                        else
                            project = new Project();

                        project.TeamID = TeamID;
                        project.CreatedByID = UserID;
                    }
                    project.Name=model.Name;

                    var res = repo.SaveProject(project);
                    if (res != null)
                    {
                        var teamMember = repo.GetTeamMember(UserID, TeamID);
                        if (teamMember != null && !teamMember.DefaultProjectID.HasValue)
                        {
                            var defProjRes = userService.SaveDefaultProjectForTeam(UserID, TeamID, project.ID);
                        }
                        return Json(new { Status = "Success", Message = "Project created successfully" });
                    }
                }
                return Json(new { Status = "Error", Message = "Required fields are missing" });
            }
            catch (Exception ex)
            {
                log.Error(ex);
                return Json(new { Status = "Error", Message = "Error in saving project" });
            }
        }
 public Project SaveProject(Project project)
 {
     if (project.ID == 0)
     {
         project.CreatedDate = DateTime.UtcNow;
         db.Projects.Add(project);
     }
     else
     {
         db.Entry(project).State = EntityState.Modified;
     }
     db.SaveChanges();
     return project;
 }