private async void AfatiKerkesavePrej5Diteve() { // -------------- Kalimi i afatit te kerkesave per blerjen e pikturave ------ KronologjiaShportes kronologjiaKerkeses = new KronologjiaShportes(); var kerkesat = kronologjiaKerkeses.getGjendjaKerkesave(); foreach (var item in kerkesat) { if (DateTime.Now - item.Koha > TimeSpan.FromDays(5)) { //Fshirja e lista e kerkesave KronologjiaShportes fshirjaKerkeses = new KronologjiaShportes(item); //Fshirja e porosise ne tabelen Shporta Shporta row = await _context.Shporta.FindAsync(item.IdShportes); _context.Shporta.Remove(row); //Kolona Shporta, ne tabelen Pikturat behet null, dhe disponueshmeria 'jo e shitur' var piktura = await _context.Pikturat.Where(a => a.Shporta == item.IdShportes).ToListAsync(); piktura[0].Shporta = null; piktura[0].Disponueshmeria = "Jo e Shitur"; _context.Update(piktura[0]); await _context.SaveChangesAsync(); } } }
public async Task <IActionResult> FshirjaKerkesesPerBlerje(int?id) { //Fshirja e porosise ne tabelen Shporta Shporta item = await _context.Shporta.FindAsync(id); _context.Shporta.Remove(item); //Kolona Shporta, ne tabelen Pikturat behet null, dhe disponueshmeria 'jo e shitur' var piktura = await _context.Pikturat.Where(a => a.Shporta == id).ToListAsync(); piktura[0].Shporta = null; piktura[0].Disponueshmeria = "Jo e Shitur"; _context.Update(piktura[0]); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(MenagjimiBlerjeve))); }
public async Task <IActionResult> KonfirmimiBlerjeve(int?id) { //kolona blerja behet true, ne tabelen Shporta Shporta shporta = await _context.Shporta.FindAsync(id); shporta.Blerja = true; _context.Update(shporta); //Kolona Shporta, ne tabelen Pikturat behet null var piktura = await _context.Pikturat.Where(a => a.Shporta == id).ToListAsync(); piktura[0].Shporta = null; piktura[0].Disponueshmeria = "Shitur"; _context.Update(piktura[0]); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(MenagjimiBlerjeve))); }
public async Task <IActionResult> ShportaBlerja(int?id, decimal?cmimi) { if (id == null || cmimi == null) { return(NotFound()); } //piktura var piktura = await _context.Pikturat.FindAsync(id); if (piktura.Disponueshmeria == "Jo e Shitur") { //modeli per insertimin e te dhenave ne tabelen Shporta Shporta shporta = new Shporta(); //email i uzerit shporta.Id_UseriKlient = User.Identity.Name; shporta.Id_Piktura = (int)id; shporta.Cmimi = (decimal)cmimi; shporta.Blerja = false; //Ruajtja e porosise ne shport _context.Add(shporta); await _context.SaveChangesAsync(); //vendosja e te dhenave per rezervim dhe id te shportes ne tabelen Pikturat piktura.Disponueshmeria = "Rezervuar"; piktura.Shporta = shporta.Id_Shporta; _context.Update(piktura); await _context.SaveChangesAsync(); //vendosja e id dhe kohes se rezervimit ne objekt. KronologjiaShportes kronologjiaKerkeses = new KronologjiaShportes(shporta.Id_Shporta); } return(RedirectToAction("ShportaBlerjeve", "Administrimi")); }