public IActionResult aInvitations([FromBody] User_Project user_project) { _context.Users_Projects.Add(user_project); var userInDb = _context.Users_Invites.SingleOrDefault(u => u.Email == user_project.Email && u.ProjectId == user_project.ProjectId); _context.Users_Invites.Remove(userInDb); _context.SaveChanges(); return(Ok(true)); }
protected void Assign_OnClick(object sender, EventArgs e) { var project = projectList.SelectedItem.Text; var userLis = Request.Form[userList.UniqueID]; var list = new List <string>(); if (!string.IsNullOrEmpty(userLis)) { list = userLis.Split(',').ToList(); } else { Page.ClientScript.RegisterClientScriptBlock(GetType(), "alert", "alert('Please select user to assign to project')", true); return; } var usList = new List <int>(list.Count); var report = string.Empty; for (var i = 0; i < list.Count; i++) { usList.Add(Convert.ToInt32(list[i])); } var proj = _projectService.GetProjectByName(project); foreach (var selectedUser in usList) { var userProj = new User_Project { created_at = DateTime.Now, modified_at = DateTime.Now, proj_id = (int)proj.id, user_id = selectedUser }; var userSelected = _projectService.GetUserById(selectedUser); _insendluEntities.User_Project.Add(userProj); var hidd = _insendluEntities.SaveChanges(); report += string.Format("{0}, ", userSelected.name); } report += string.Format(" has / have been added to proposal {0}", project); GetActiveProposals(); GetUserList(); Page.ClientScript.RegisterClientScriptBlock(GetType(), "alert", "alert('" + report + "')", true); }
public int SaveUserProject(Project pro, User user) { var userProj = new User_Project { created_at = DateTime.Today, modified_at = DateTime.Today, proj_id = (int)pro.id, user_id = (int)user.id }; _insendluEntities.User_Project.Add(userProj); return(_insendluEntities.SaveChanges()); }