// GET: api/Users/5 public HttpResponseMessage Get(int id) { return(new HttpResponseMessage(HttpStatusCode.OK) { Content = new ObjectContent <String>(LogicUsers.GetUserName(id), new JsonMediaTypeFormatter()) }); }
// PUT: api/Users/5 it also good to connect user to the new TeamLeader public HttpResponseMessage Put([FromBody] User value) { if (ModelState.IsValid) { return((LogicUsers.UpdateUser(value)) ? new HttpResponseMessage(HttpStatusCode.OK) : new HttpResponseMessage(HttpStatusCode.BadRequest) { Content = new ObjectContent <String>("Can not update in DB", new JsonMediaTypeFormatter()) }); } ; List <string> ErrorList = new List <string>(); //if the code reached this part - the user is not valid foreach (var item in ModelState.Values) { foreach (var err in item.Errors) { ErrorList.Add(err.ErrorMessage); } } return(new HttpResponseMessage(HttpStatusCode.BadRequest) { Content = new ObjectContent <List <string> >(ErrorList, new JsonMediaTypeFormatter()) }); }
// GET: api/Users public HttpResponseMessage Get() { return(new HttpResponseMessage(HttpStatusCode.OK) { Content = new ObjectContent <List <User> >(LogicUsers.GetAllUsers(), new JsonMediaTypeFormatter()) }); }
public HttpResponseMessage Login([FromBody] UserHelp value) { if (ModelState.IsValid) { User user = LogicUsers.GetAllUsers().FirstOrDefault(p => p.UserName == value.UserName && p.Password == value.Password); return((user != null) ? new HttpResponseMessage(HttpStatusCode.OK) { Content = new ObjectContent <User>(user, new JsonMediaTypeFormatter()) }: new HttpResponseMessage(HttpStatusCode.OK) { Content = new ObjectContent <String>("You aren't singed", new JsonMediaTypeFormatter()) }); } List <string> ErrorList = new List <string>(); //if the code reached this part - the user is not valid foreach (var item in ModelState.Values) { foreach (var err in item.Errors) { ErrorList.Add(err.ErrorMessage); } } return(new HttpResponseMessage(HttpStatusCode.BadRequest) { Content = new ObjectContent <List <string> >(ErrorList, new JsonMediaTypeFormatter()) }); }
// DELETE: api/Users/5 public HttpResponseMessage Delete(int id) { return((LogicUsers.RemoveUser(id)) ? new HttpResponseMessage(HttpStatusCode.OK) : new HttpResponseMessage(HttpStatusCode.BadRequest) { Content = new ObjectContent <String>("Can not remove from DB", new JsonMediaTypeFormatter()) }); }
public HttpResponseMessage GetUsersAndGrafOfProject(string nameProject) { List <User> users = LogicUsers.GetUsersByNameOfProject(nameProject); Dictionary <UserProject, double> myGraf = LogicProjects.GetUsersAndHoursThatWorkedOnProject(LogicProjects.GetProjectByNameProject(nameProject).IdProject); return(new HttpResponseMessage(HttpStatusCode.OK) { Content = new ObjectContent <MyClass>(new MyClass() { Users = users, MyGraf = myGraf }, new JsonMediaTypeFormatter()) }); }
public static HttpResponseMessage GetUsersDevidedToProjectsUnderTeamLeader(int idTeamLeader) { Dictionary <Project, List <User> > allProjectsWithThemUsersUnderTeamLeader = new Dictionary <Project, List <User> >(); List <Project> allProjectsUnderTeamLeader = LogicProjects.GetProjectsUnderTeamLeader(idTeamLeader); foreach (var item in allProjectsUnderTeamLeader) { allProjectsWithThemUsersUnderTeamLeader.Add(item, LogicUsers.GetUsersOfProject(item.IdProject)); } return(new HttpResponseMessage(HttpStatusCode.OK) { Content = new ObjectContent <Dictionary <Project, List <User> > >(allProjectsWithThemUsersUnderTeamLeader, new JsonMediaTypeFormatter()) }); }
public HttpResponseMessage GetUsersAndGrafOfProjmect(string nameProject) { List <User> usersNotFinishProject = new List <User>(); Project myProject = LogicProjects.GetProjectByNameProject(nameProject); Dictionary <UserProject, double> UsersAndHoursWorkedOnProject; if (myProject.Active) { UsersAndHoursWorkedOnProject = LogicProjects.GetUsersAndHoursThatWorkedOnProject(myProject.IdProject); foreach (var item in UsersAndHoursWorkedOnProject) { if (item.Value != 100) { usersNotFinishProject.Add(LogicUsers.GetUserByIdUser(item.Key.IdUser)); } } } return(new HttpResponseMessage(HttpStatusCode.OK) { Content = new ObjectContent <List <User> >(usersNotFinishProject, new JsonMediaTypeFormatter()) }); }
public HttpResponseMessage GetAllTeamLeaders() { return(Request.CreateResponse(HttpStatusCode.OK, LogicUsers.GetAllTeamLeader())); }
public HttpResponseMessage GetAllUsersUnderTheDirectionOfTheTeamLeader(int idTeamLeader) { return(Request.CreateResponse(HttpStatusCode.OK, LogicUsers.GetAllUsersUnderTeamLeader(idTeamLeader))); }
public ILogicUsers getUsersLogic(UserManager <AppUser> manager) { return(LogicUsers.GetInstance(manager)); }