Esempio n. 1
0
 public async Task <Response> Delete(int id)
 {
     if (NullPropertyVerifier.IsIdValid(id))
     {
         return(await _userDAL.Delete(id));
     }
     return(await ResponseModels.FailedResponseModel($"{id.toString()} is not a valid ID."));
 }
Esempio n. 2
0
 public async Task <Response> Update(User item)
 {
     if (item != null)
     {
         return(await _userDAL.Update(item));
     }
     return(await ResponseModels.FailedResponseModel("Object cannot be null."));
 }
Esempio n. 3
0
 public async Task <Response> Insert(User item)
 {
     NullPropertyVerifier.IsAnyPropertyNull(item);
     if (!NullPropertyVerifier.NullProperties.HasNullProperties())
     {
         return(await _userDAL.Insert(item));
     }
     else
     {
         return(await ResponseModels.FailedResponseModel(NullPropertyVerifier.NullProperties.NullPropertiesToSting()));
     }
 }
Esempio n. 4
0
        public async Task <Response> Insert(User item)
        {
            try
            {
                using var context = _db;
                await context.Users.AddAsync(item);

                await context.SaveChangesAsync();

                return(await ResponseModels.SuccessResponseModel());
            }
            catch (Exception e)
            {
                return(await ResponseModels.FailedResponseModel(e.ToString()));
            }
        }
Esempio n. 5
0
        public async Task <Response> Delete(int id)
        {
            try
            {
                using var context = _db;
                context
                .Users
                .Remove(new User()
                {
                    Id = id
                });
                await context.SaveChangesAsync();

                return(await ResponseModels.SuccessResponseModel());
            }
            catch (Exception e)
            {
                return(await ResponseModels.FailedResponseModel(e.ToString()));
            }
        }