Example #1
0
 public async Task<ViewResult> DevisView()
 {
     using (var db = new AssurContext())
     {
         var model = await db.Devises.OrderByDescending(d=>d.DateDemande).ToListAsync();
         return View(model);
     }         
 }
Example #2
0
 public ActionResult Delete(Guid devisGuid)
 {           
     using (var db = new AssurContext())
     {
         var devis = db.Devises.Find(devisGuid);
         db.Devises.Remove(devis);
         db.Entry(devis).State = EntityState.Deleted;
          db.SaveChanges();
         return RedirectToAction("Demandes");
     }
 }
Example #3
0
        public async Task<RedirectToRouteResult> Save(Devis devis)
        {
            if (!ModelState.IsValid) return RedirectToAction("Index");

            using (var db =new AssurContext())
            {
                devis.DevisGuid = Guid.NewGuid();
                devis.DateDemande = DateTime.Now;
                db.Devises.Add(devis);
                await db.SaveChangesAsync();
                await SendEmail.Report(devis);
                return RedirectToAction("ThankYou");
            }
        }
Example #4
0
        public async Task<ViewResult> Demandes(int? page)
        {
            using (var db = new AssurContext())
            {

                //db.Devises.AddRange(SeedData.Seed(100));
                //await db.SaveChangesAsync();

                var pageno = page == null ? 1 : int.Parse(page.ToString());
                const int pageSize = 10;
                var totalCount = await db.Devises.CountAsync();
                
                var pager = new Pager<Devis>(
                    await db.Devises
                    .OrderByDescending(d=>d.Nom)
                    .Skip((pageno - 1) * pageSize)
                    .Take(pageSize)
                    .ToListAsync(), pageno, pageSize, totalCount);

                return View(pager);
            }
        }