public async Task <bool> Delete(long id) { try { _invillaContext = new InvillaContext(); _serviceLoans = new ServiceLoans(); if (id == null || await _serviceLoans.GetLoanFriendById(id)) { return(false); } var loginDB = _invillaContext.Logins.Select(x => x).Where(x => x.Id == id).FirstOrDefault(); var roleDB = _invillaContext.Roles.Select(x => x).Where(x => x.Id == loginDB.IdRole).FirstOrDefault(); if (roleDB != null) { return(false); } _invillaContext.Remove(loginDB); _invillaContext.SaveChanges(); return(true); } catch (Exception ex) { return(false); } }
public async Task <bool> Delete(long id) { try { _invillaContext = new InvillaContext(); _serviceLoans = new ServiceLoans(); if (id == null || await _serviceLoans.GetLoanGameById(id)) { return(false); } var gameDB = _invillaContext.Games.Select(x => x).Where(x => x.Id == id).FirstOrDefault(); _invillaContext.Remove(gameDB); _invillaContext.SaveChanges(); return(true); } catch (Exception ex) { return(false); } }
public LoansController(ILogger <LoansController> logger) { _logger = logger; _serviceLoans = new ServiceLoans(); }