public IActionResult VerificaCarte(BookViewModel view) { var ctx = repository.VerifyBookByTitleAsync(view.CARTE.Titlu.Trim()).Result.ToList(); int nrCartiInregistrate = repository.GetNumberOfExistingBooksByTitleAsync(view.CARTE.Titlu.Trim()).Result; if (ctx.LongCount() == 0) { ; //MessageBox((IntPtr)0, "Cartea nu exista in biblioteca.", "Message Box", 0); } else { int nrCartiImprumutate = repository.GetNumberOfBorrowedBooksByTitleAsync(view.CARTE.Titlu.Trim()).Result; if (nrCartiInregistrate == nrCartiImprumutate) { DateTime dataScadenta = repository.ShowDateToBorrowBookAsync(view.CARTE.Titlu.Trim()).Result; } else if (nrCartiInregistrate > nrCartiImprumutate) { ; //content = "Cartea exista in biblioteca.\nVa rugam sa completati formularul 'Imprumuta Carte' \n"; } //MessageBox((IntPtr)0, content, "Message Box", 0); } return(View(view)); }
public async Task <IActionResult> InsertLoan(LoanViewModel view) { int cititorId = 0, carteId = 0; var exista_cititor = repository.VerifyReaderByNameAsync(view.CITITOR.Nume.Trim() + " " + view.CITITOR.Prenume.Trim()).Result.ToList(); if (exista_cititor.LongCount() > 0) { var queryReader = repository.GetReaderAsync(exista_cititor[0].CititorId).Result; cititorId = queryReader.CititorId; int nrCartiDupaTitluCARTE = repository.GetNumberOfExistingBooksByTitleAsync(view.CARTE.Titlu.Trim()).Result; int nrCartiImprumutateDupaTitlu = repository.GetNumberOfBorrowedBooksByTitleAsync(view.CARTE.Titlu.Trim()).Result; if (nrCartiImprumutateDupaTitlu == nrCartiDupaTitluCARTE) { var queryDataToLoan = repository.ShowDateToBorrowBookAsync(view.CARTE.Titlu.Trim()).Result; } } else { return(RedirectToAction("NotPossible", "Home", view)); } var exista_carte = repository.VerifyBookByTitleAsync(view.CARTE.Titlu.Trim()).Result.ToList(); if (exista_carte.LongCount() > 0) { carteId = exista_carte[0].CarteId; } else { return(RedirectToAction("NotPossible", "Home", view)); } DateTime dataImprumut = DateTime.Now; DateTime dataScadenta = dataImprumut.AddDays(15); DateTime restituire = new DateTime(1900, 1, 1); IMPRUMUT loan = new IMPRUMUT { CarteId = carteId, CititorId = cititorId, DataImprumut = dataImprumut, DataScadenta = dataScadenta, DataRestituire = restituire, }; view.IMPRUMUT = loan; await repository.InsertLoanAsync(view.IMPRUMUT); return(RedirectToAction("AfisareImprumuturi", "Loan", view)); }