Beispiel #1
0
        public IHttpActionResult PostProjectDirec(ProjectDirec projectDirec)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.ProjectDirecs.Add(projectDirec);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (ProjectDirecExists(projectDirec.UserName))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = projectDirec.UserName }, projectDirec));
        }
Beispiel #2
0
        public IHttpActionResult PutProjectDirec(string id, ProjectDirec projectDirec)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != projectDirec.UserName)
            {
                return(BadRequest());
            }

            db.Entry(projectDirec).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ProjectDirecExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #3
0
        public IHttpActionResult GetProjectDirec(string id)
        {
            ProjectDirec projectDirec = db.ProjectDirecs.Find(id);

            if (projectDirec == null)
            {
                return(NotFound());
            }

            return(Ok(projectDirec));
        }
Beispiel #4
0
        public IHttpActionResult DeleteProjectDirec(string id)
        {
            ProjectDirec projectDirec = db.ProjectDirecs.Find(id);

            if (projectDirec == null)
            {
                return(NotFound());
            }

            db.ProjectDirecs.Remove(projectDirec);
            db.SaveChanges();

            return(Ok(projectDirec));
        }