public ActionResult <List <Idea> > GetIdeasByIdeaspaceId(int ideaspaceId) { Ideaspace ids = dbc.Ideaspace.Find(ideaspaceId); if (ids == null) { return(NotFound()); } List <Idea> ideasById = dbc.Idea.Where(i => i.IdeaspaceId == ideaspaceId).OrderByDescending(i => i.Votecounter).ToList <Idea>(); return(Ok(ideasById)); }
public ActionResult <Ideaspace> GetIdeaspace(string name, string password) { Ideaspace ideaspace = dbc.Ideaspace.Where(i => i.Name == name).FirstOrDefault();; if (ideaspace != null) { byte[] passwordHash = Hash(password, Convert.FromBase64String(ideaspace.PasswordSalt)); var pol = Encoding.UTF8.GetBytes(ideaspace.Password); bool correct = Convert.FromBase64String(ideaspace.Password).SequenceEqual(passwordHash); if (correct) { return(Ok(ideaspace)); } else { return(Unauthorized()); } } else { return(NotFound()); } }
public ActionResult <Ideaspace> PostIdeaSpace(Ideaspace ideaspace) { //Ideaspace ideaspace = new Ideaspace { Name = name, Password = password, Description = description }; var q = dbc.Ideaspace.Where(i => i.Name == ideaspace.Name).FirstOrDefault(); if (q != null) { return(Unauthorized()); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } byte[] salt = new byte[16]; ideaspace.Password = Convert.ToBase64String(Hash(ideaspace.Password, salt)); ideaspace.PasswordSalt = Convert.ToBase64String(salt); dbc.Ideaspace.Add(ideaspace); dbc.SaveChanges(); return(Ok(ideaspace)); }
public ActionResult <Ideaspace> GetIdeaspaceById(int ideaspaceid) { Ideaspace ideaspace = dbc.Ideaspace.Where(i => i.IdeaspaceId == ideaspaceid).FirstOrDefault(); return(Ok(ideaspace)); }