Example #1
0
        public IHttpActionResult Register([FromBody] RegisterViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var user = new User()
            {
                Email = model.Email, Name = model.Name, Password = model.Password
            };

            database.Add(user);

            database.CommitAsync <User>();

            return(Ok(user));
        }
Example #2
0
        public IHttpActionResult AddRequest([FromBody] AddPostViewModel postViewModel)
        {
            if (postViewModel == null)
            {
                return(BadRequest());
            }

            var newPost = new Request()
            {
                Submitter = database.Get <User>().SingleOrDefault(u => u.Email == HttpContext.Current.User.Identity.Name),
                Summary   = postViewModel.Summary,
                Details   = postViewModel.Details
            };

            database.Add(newPost);
            database.CommitAsync <Post>();

            return(Ok(newPost));
        }