public static User ToEntity(this IncomingFullUserDTO user) { if (user == null) { return(null); } // create temporary liked ads list List <Vehicle> likedAds = new List <Vehicle>(); if (user.LikedAds != null) { foreach (int id in user.LikedAds) { likedAds.Add(new Vehicle { Id = id }); } } User u = new() { Username = user.Username, Phone = user.Phone, Email = user.Email, HashedPassword = Utilities.EncryptPassword(user.Password, user.Username), Role = user.Role ?? UserRole.User, LikedAds = likedAds }; return(u); }
public Task <string> AddFullUser(IncomingFullUserDTO user) { return(_repository.AddUser(user.ToEntity())); }
public async Task <ActionResult <IncomingFullUserDTO> > PostFullUser([FromBody][Required] IncomingFullUserDTO value) { return(value == null? BadRequest() : await _services.AddFullUser(value) == null?Conflict() : StatusCode(201, value)); }