public IHttpActionResult PutTodo(int id, Todo todo)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != todo.ToDoEntryId)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #2
0
        // POST: api/ToDo
        public Models.ToDoList Post(Models.ToDoList todo)
        {
            _dataContext.todos.Add(todo);

            _dataContext.SaveChanges();

            return(todo);
        }
Beispiel #3
0
        /// <summary>
        /// Post Data
        /// </summary>
        /// <param name="request"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        public override Task <ToDoPostResponse> PostToDoItem(ToDoData request, ServerCallContext context)
        {
            _dataContext.ToDoDbItems.Add(request);
            var result = _dataContext.SaveChanges();

            if (result > 0)
            {
                return(Task.FromResult(new ToDoPostResponse()
                {
                    Status = true,
                    StatusCode = 100,
                    StatusMessage = "Added Successfully"
                }));
            }
            else
            {
                return(Task.FromResult(new ToDoPostResponse()
                {
                    Status = false,
                    StatusCode = 500,
                    StatusMessage = "Issue Occured."
                }));
            }
        }
Beispiel #4
0
 public void Add(TEntity obj)
 {
     Db.Set <TEntity>().Add(obj);
     Db.SaveChanges();
 }
Beispiel #5
0
 public void Add(ToDoItem item)
 {
     _context.Add(item);
     _context.SaveChanges();
 }