public async Task <ActionResult <signUpreturnvalues> > signUp([FromForm] userModel user) { var returnvalues = new signUpreturnvalues(); var mail = _context.users.Where(x => x.email_address == user.email_address).FirstOrDefault(); if (mail != null) { var error = new errormodel(); error.error = "E-MAil allready used"; return(Unauthorized(error)); } var suser = new users(); suser.email_address = user.email_address; suser.password = tools.hashpassword(user.password); if (user.role.ToLower() == "developer") { suser.role = 1; } else if (user.role.ToLower() == "employer") { suser.role = 2; } suser.iscomplete = false; _context.users.Add(suser); await _context.SaveChangesAsync(); returnvalues.Registered = true; returnvalues.UserID = suser.ID.ToString(); returnvalues.Status = "user was created successfully"; return(returnvalues); }
public async Task <ActionResult <compteteprofilepost> > GetUsers(int id) { if (!_context.users.Where(x => x.ID == id).FirstOrDefault().iscomplete) { var error = new errormodel(); error.error = "profile is not completed"; return(NotFound(error)); } var model = new compteteprofilepost(); var compmodel = _context.complete_profile.Where(x => x.ID == id).FirstOrDefault(); model.user_name = compmodel.user_name; model.email_address = compmodel.email_address; model.gender = compmodel.gender; model.age = compmodel.age; model.position = _context.developer.Where(x => x.ID == id).FirstOrDefault().position; var role = _context.users.Where(x => x.ID == id).FirstOrDefault().role; if (role == 1) { model.role = "Developer"; } var skills = _context.skkils.Where(x => x.developerID == id).ToList(); var list = new List <string>(); foreach (var item in skills) { list.Add(item.skill.Trim()); } model.skills = list; return(model); }