Example #1
0
        public IHttpActionResult PostRelease(Release release)
        {
            release.ReleaseID = CommonModel.GetNewGUIDIfEmpty(release.ReleaseID);
            release           = CommonModel.AssigneLoginInfo <Release>(release);
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Releases.Add(release);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (ReleaseExists(release.ReleaseID))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = release.ReleaseID }, release));
        }