public IHttpActionResult PutTreatmentView(string id, TreatmentView treatmentView)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != treatmentView.PetName)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IHttpActionResult PostTreatmentView(TreatmentView treatmentView)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.TreatmentViews.Add(treatmentView);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (TreatmentViewExists(treatmentView.PetName))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = treatmentView.PetName }, treatmentView));
        }
Ejemplo n.º 3
0
        public async Task <IHttpActionResult> PutTreatmentView(int id, TreatmentView treatmentView)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != treatmentView.TreatmentId)
            {
                return(BadRequest());
            }

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

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TreatmentViewExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public async Task <IHttpActionResult> GetTreatmentView(int id, string PetName, int ProcedureID, DateTime Date)
        {
            TreatmentView treatmentView = await db.TreatmentViews.FirstOrDefaultAsync(t => t.OwnerID == id && t.PetName == PetName && t.ProcedureID == ProcedureID && t.Date == Date);

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

            return(Ok(treatmentView));
        }
Ejemplo n.º 5
0
        public async Task <IHttpActionResult> GetTreatmentView(int id)
        {
            TreatmentView treatmentView = await db.TreatmentViews.FindAsync(id);

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

            return(Ok(treatmentView));
        }
        public IHttpActionResult DeleteTreatmentView(string id)
        {
            TreatmentView treatmentView = db.TreatmentViews.Find(id);

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

            db.TreatmentViews.Remove(treatmentView);
            db.SaveChanges();

            return(Ok(treatmentView));
        }
Ejemplo n.º 7
0
        public async Task <IHttpActionResult> DeleteTreatmentView(int id)
        {
            TreatmentView treatmentView = await db.TreatmentViews.FindAsync(id);

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

            db.TreatmentViews.Remove(treatmentView);
            await db.SaveChangesAsync();

            return(Ok(treatmentView));
        }