public IHttpActionResult GetComByTask(int idtask)
        {
            var contexte = new ToDoListWebAPI20180823030718_dbEntities();
            var comments = contexte.Comments.Where(n => n.IDTask == idtask).FirstOrDefault();

            return(Ok(comments));
        }
Ejemplo n.º 2
0
        public IHttpActionResult GetDone(int iduser)
        {
            var contexte = new ToDoListWebAPI20180823030718_dbEntities();
            var tasks    = contexte.Tasks.Where(n => n.TaskState == "done" & n.IDUserCreator == iduser).OrderBy(n => n.ID).ToList();

            return(Ok(tasks));
        }
        public IHttpActionResult GetValdByMailAndPwd(string identifiant, string pwd)
        {
            var contexte = new ToDoListWebAPI20180823030718_dbEntities();
            var User     = contexte.Users.Where(n => n.Mail == identifiant | n.Pseudo == identifiant & n.Pwd == pwd).FirstOrDefault();

            return(Ok(User));
        }
Ejemplo n.º 4
0
        public IHttpActionResult Get()
        {
            var contexte = new ToDoListWebAPI20180823030718_dbEntities();
            var users    = contexte.Users.OrderBy(n => n.ID).ToList();

            return(Ok(users));
        }
Ejemplo n.º 5
0
        public IHttpActionResult PostAdd(Tasks task)
        {
            var contexte = new ToDoListWebAPI20180823030718_dbEntities();

            contexte.Tasks.Add(task);
            contexte.SaveChanges();
            return(Ok());
        }
        public IHttpActionResult Delete(int id)
        {
            var contexte = new ToDoListWebAPI20180823030718_dbEntities();
            var comment  = contexte.Comments.Where(n => n.ID == id).FirstOrDefault();

            contexte.Comments.Remove(comment);
            contexte.SaveChanges();
            return(Ok());
        }
        public IHttpActionResult Put(Comments Com)
        {
            var contexte = new ToDoListWebAPI20180823030718_dbEntities();
            var comEdit  = contexte.Comments.Where(n => n.ID == Com.ID).FirstOrDefault();

            comEdit.Content = Com.Content;
            contexte.SaveChanges();
            return(Ok());
        }
        public IHttpActionResult Post(Comments Com)
        {
            var contexte = new ToDoListWebAPI20180823030718_dbEntities();

            contexte.Comments.Add(Com);
            contexte.SaveChanges();

            return(Ok());
        }
Ejemplo n.º 9
0
        public IHttpActionResult Post(Users user)
        {
            var contexte = new ToDoListWebAPI20180823030718_dbEntities();

            contexte.Users.Add(user);
            contexte.SaveChanges();

            return(Ok());
        }
Ejemplo n.º 10
0
        public IHttpActionResult Get(int id)
        {
            var contexte = new ToDoListWebAPI20180823030718_dbEntities();
            var task     = contexte.Tasks.Where(n => n.ID == id).FirstOrDefault();

            //var toto = "{id: " + task.ID + ", Note: " + task.Note + ", State: " + task.TaskState + " }";
            //return Ok(toto);

            return(Ok(task));
        }
Ejemplo n.º 11
0
        public IHttpActionResult Put(Users user)
        {
            var contexte = new ToDoListWebAPI20180823030718_dbEntities();
            var userEdit = contexte.Users.Where(n => n.ID == user.ID).FirstOrDefault();

            userEdit.Mail = user.Mail;
            userEdit.Pwd  = user.Pwd;
            contexte.SaveChanges();
            return(Ok());
        }
Ejemplo n.º 12
0
        public IHttpActionResult Put(Tasks task)
        {
            var contexte = new ToDoListWebAPI20180823030718_dbEntities();
            var taskEdit = contexte.Tasks.Where(n => n.ID == task.ID).FirstOrDefault();

            taskEdit.TaskState = task.TaskState;
            taskEdit.Note      = task.Note;
            taskEdit.DeadLine  = task.DeadLine;
            //contexte.Tasks.;
            contexte.SaveChanges();
            return(Ok());
        }
Ejemplo n.º 13
0
        public IHttpActionResult GetAllAsync()
        {
            var contexte = new ToDoListWebAPI20180823030718_dbEntities();
            var tasks    = contexte.Tasks.OrderBy(n => n.ID).ToList();


            //var toto = "";
            //foreach (var item in tasks)
            //{
            //    toto += " / " + "{id: " + item.ID + ", Note: " + item.Note + ", State: " + item.TaskState + " }";
            //}
            //return Ok(toto);

            return(Ok(tasks));
        }
Ejemplo n.º 14
0
        public IHttpActionResult Delete(int id)
        {
            var             contexte = new ToDoListWebAPI20180823030718_dbEntities();
            var             task     = contexte.Tasks.Where(n => n.ID == id).FirstOrDefault();
            List <Comments> comments = contexte.Comments.Where(n => n.IDTask == id).ToList();

            foreach (var item in comments)
            {
                contexte.Comments.Remove(item);
            }

            contexte.Tasks.Remove(task);
            contexte.SaveChanges();
            return(Ok());
        }