示例#1
0
        public IHttpActionResult Delete(int id)
        {
            Model_Task model_BAL_Task = db.DB_Tasks.Find(id);

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != model_BAL_Task.TaskID)
            {
                return(BadRequest());
            }

            try
            {
                BAL_Task.Delete(model_BAL_Task);
            }

            catch (DbUpdateConcurrencyException)
            {
                if (!BAL_Task.TaskExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            return(Ok(model_BAL_Task));
        }
示例#2
0
        public IHttpActionResult Put(int id, Model_Task model_BAL_Task)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != model_BAL_Task.TaskID)
            {
                return(BadRequest());
            }
            try
            {
                BAL_Task.Put(model_BAL_Task);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!BAL_Task.TaskExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
示例#3
0
        public IHttpActionResult Post(Model_Task model_BAL_Task)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            BAL_Task.Post(model_BAL_Task);

            return(CreatedAtRoute("DefaultApi", new { id = model_BAL_Task.TaskID }, model_BAL_Task));
        }
示例#4
0
 public void Delete(Model_Task model_DAL_Task)
 {
     model_DAL_Task.IsCompleted     = true;
     db.Entry(model_DAL_Task).State = EntityState.Modified;
     db.SaveChangesAsync();
 }
示例#5
0
 public void Post(Model_Task model_DAL_Task)
 {
     db.DB_Tasks.Add(model_DAL_Task);
     db.SaveChangesAsync();
 }
示例#6
0
 public void Put(Model_Task model_DAL_Task)
 {
     db.Entry(model_DAL_Task).State = EntityState.Modified;
     db.SaveChangesAsync();
 }