Ejemplo n.º 1
0
        public TaskList Post(TaskList value)
        {
            var userName = Request.GetUserPrincipal().Identity.Name;

            value.Id = Guid.NewGuid();
            value.UserName = userName;

            this.model.TaskLists.Add(value);
            this.model.SaveChanges();

            return value;
        }
Ejemplo n.º 2
0
        public TaskList Post(TaskList value)
        {
            var userName = this.User.Identity.Name;

            value.Id = Guid.NewGuid();
            value.UserName = userName;

            this.model.TaskLists.Add(value);
            this.model.SaveChanges();

            return value;
        }
Ejemplo n.º 3
0
        public TaskList Put(Guid id, TaskList value)
        {
            var userName = this.User.Identity.Name;

            var belongsToUser = this.model.TaskLists.Count(o => o.Id == id && o.UserName == userName) == 1;
            if (!belongsToUser)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }

            // Don't allow to change username
            value.UserName = userName;

            this.model.TaskLists.Attach(value);
            this.model.Entry<TaskList>(value).State = System.Data.EntityState.Modified;
            this.model.SaveChanges();

            return value;
        }