Beispiel #1
0
        public IHttpActionResult PutOtherOxpense(int id, string expenseEssence, OtherOxpense otherOxpense)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != otherOxpense.DocId || !expenseEssence.Equals(otherOxpense.ExpenseEssence))
            {
                return(BadRequest());
            }

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

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!OtherOxpenseExists(id, otherOxpense.ExpenseEssence))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #2
0
        public IHttpActionResult DeleteOtherOxpense(int id)
        {
            OtherOxpense otherOxpense = db.OtherOxpenses.Find(id);

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

            db.OtherOxpenses.Remove(otherOxpense);
            db.SaveChanges();

            return(Ok(otherOxpense));
        }