Exemplo n.º 1
0
        public async Task <IActionResult> Add([FromBody] TEntity entity)
        {
            if (_BlockedFromAdd.Any(eName => eName == typeof(TEntity).Name))
            {
                return(BadRequest(new Error()
                {
                    Message = "Oops! this action is not available for this entity !!"
                }));
            }
            // add entity and saveChanges
            await Task.Run(() => _service.Add(entity));

            return(_GetEntityResult(entity));
        }
 public IActionResult SignUp(SignUp signUp)
 {
     // (1) Generate password Hash and salt
     // (_) Mapping from SignUp [View Model] to User [Entity Model]
     user = UserHelpers.ToUser(signUp);
     // (2) insert the User
     _service.Add(user);
     // (3) Map the Entity User to View User [VUser]
     vUser = _mapper.Map <UserView>(user);
     // (4) if everything is ok, return the [vUser - accessToken - refreshToken]
     return(Ok(new
     {
         User = vUser,
         AccessToken = UserHelpers.GetToken(vUser)
     }
               ));
 }