Esempio n. 1
0
        public IHttpActionResult Putsample_type(int id, sample_type sample_type)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.BadRequest(this.ModelState));
            }

            if (id != sample_type.sam_type_Id)
            {
                return(this.BadRequest());
            }

            this.db.Entry(sample_type).State = EntityState.Modified;
            var sample_typeExists = this.db.sample_type.Count(e => e.sam_type_Id == id) > 0;

            try
            {
                this.db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!sample_typeExists)
                {
                    return(this.NotFound());
                }
                throw;
            }

            return(this.StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 2
0
        public IHttpActionResult Postsample_type(sample_type sample_type)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.BadRequest(this.ModelState));
            }

            this.db.sample_type.Add(sample_type);
            this.db.SaveChanges();

            return(this.CreatedAtRoute("DefaultApi", new { id = sample_type.sam_type_Id }, sample_type));
        }