Esempio n. 1
0
 public bool DeleteUser(Guid userId, bool isSeller)
 {
     using (var db = new SqlConnection(_connectionString))
     {
         _addressRepo.DeleteUserAddresses(userId);
         _paymentTypeRepo.DeleteAllPaymentTypesByUserId(userId);
         if (isSeller)
         {
             var productsToDelete = _productRepo.GetProductsByUid(userId);
             foreach (Product product in productsToDelete)
             {
                 _productRepo.DeleteProduct(product.Id);
             }
         }
         var sql        = @"UPDATE [User]
                     SET [FirstName] = 'DELETED',
                         [LastName] = 'DELETED'
                     WHERE Id = @userId";
         var parameters = new { userId };
         return(db.Execute(sql, parameters) == 1);
     }
 }