Example #1
0
        public Obiectiv Create(ObiectivPostModel obiectiv)
        {
            Obiectiv toAdd = ObiectivPostModel.ToObiectiv(obiectiv);

            context.Obiective.Add(toAdd);
            context.SaveChanges();
            return(toAdd);
        }
        public void Post([FromBody] Obiectiv obiectiv)
        {
            //if (!ModelState.IsValid)
            //{

            //}
            context.Obiective.Add(obiectiv);
            context.SaveChanges();
        }
Example #3
0
        public UserGetModel Register(RegisterPostModel registerinfo)
        {
            User existing = context.Users.FirstOrDefault(u => u.Username == registerinfo.UserName);

            if (existing != null)
            {
                return(null);
            }
            context.Users.Add(new User
            {
                Email     = registerinfo.Email,
                LastName  = registerinfo.LastName,
                FirstName = registerinfo.FirstName,
                Password  = ComputeSha256Hash(registerinfo.Password),
                Username  = registerinfo.UserName
            });
            context.SaveChanges();
            return(Authenticate(registerinfo.UserName, registerinfo.Password));
        }