Ejemplo n.º 1
0
        public ActionResult Create(Banka model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    using (ButceTakipContext context = new ButceTakipContext())
                    {
                        var count = context.Bankalar.Count();
                        context.Bankalar.Add(model);
                        context.SaveChanges();
                    }
                    TempData["OperationResult"] = new OperationResult()
                    {
                        Message = string.Format("{0} {1} başarıyla yaratıldı.", model.Aciklama, model.Sube),
                        Success = true,
                    };
                    return RedirectToAction("Index");
                }
                catch (Exception)
                {

                    TempData["OperationResult"] = new OperationResult()
                    {
                        Message = string.Format("{0} {1} hata oluştu.", model.Aciklama, model.Sube),
                        Success = false,
                    };
                }

            }
            return View(model);
        }
Ejemplo n.º 2
0
 public ActionResult Delete(Banka model)
 {
     try
     {
         using (ButceTakipContext context = new ButceTakipContext())
         {
             context.Entry<Banka>(model).State = System.Data.EntityState.Deleted;
             context.SaveChanges();
             TempData["OperationResult"] = new OperationResult()
             {
                 Message = string.Format("{0} {1} başarıyla silindi.", model.Aciklama, model.Sube),
                 Success = true,
             };
             return RedirectToActionPermanent("Index");
         }
     }
     catch (Exception)
     {
         TempData["OperationResult"] = new OperationResult()
         {
             Message = string.Format("{0} {1} silinemedi!", model.Aciklama, model.Sube),
             Success = false,
         };
         return RedirectToAction("Delete", model.Id);
     }
 }
Ejemplo n.º 3
0
        public ActionResult Edit(Banka model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    using (ButceTakipContext context = new ButceTakipContext())
                    {
                        context.Entry<Banka>(model).State = System.Data.EntityState.Modified;
                        context.SaveChanges();
                    }
                    TempData["OperationResult"] = new OperationResult()
                    {
                        Message = string.Format("{0} {1} başarıyla güncellendi.", model.Aciklama, model.Sube),
                        Success = true,
                    };
                    return RedirectToActionPermanent("Index");
                }
                catch (Exception)
                {
                    TempData["OperationResult"] = new OperationResult()
                    {
                        Message = string.Format("{0} {1} güncellenemedi.", model.Aciklama, model.Sube),
                        Success = false,
                    };
                }
            }

            return View(model);
        }