public HttpResponseMessage Put(int projectId, [FromBody] List <UserWithoutPassword> workers)
        {
            if (ModelState.IsValid)
            {
                return((LogicProjects.AddWorkerToProject(projectId, workers)) ?
                       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())
            });
        }
        public HttpResponseMessage Put([FromBody] int projectId, [FromBody] List <User> workers)
        {
            if (ModelState.IsValid)
            {
                return(LogicProjects.AddWorkerToProject(projectId, workers) ?
                       Request.CreateResponse(HttpStatusCode.OK) :
                       Request.CreateResponse(HttpStatusCode.BadRequest, "Can not update in DB"));
            }
            ;

            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(Request.CreateResponse(HttpStatusCode.BadRequest, ErrorList));
        }
        public HttpResponseMessage AddWorkersToProject(int projectId, [FromBody] List <ProjectWorker> workers)
        {
            ModelState.Remove("projectId");

            for (int i = 0; i < workers.Count; i++)
            {
                ModelState.Remove($"workers[{i}].User.ConfirmPassword");
                ModelState.Remove($"workers[{i}].User.Password");
                ModelState.Remove($"workers[{i}].User.Email");
            }

            if (ModelState.IsValid)
            {
                return((LogicProjects.AddWorkerToProject(projectId, workers)) ?
                       new HttpResponseMessage(HttpStatusCode.OK) :
                       new HttpResponseMessage(HttpStatusCode.BadRequest)
                {
                    Content = new ObjectContent <String>("Can not update in DB", new JsonMediaTypeFormatter())
                });
            }
            ;

            return(Request.CreateResponse(HttpStatusCode.BadRequest, BaseLogic.GetErorList(ModelState.Values)));
        }