public ActionResult Register(Emploies emp)
        {
            using (MyDbContext db = new MyDbContext())
            {
                if (ModelState.IsValid)
                {
                    db.Employes.Add(emp);
                    db.SaveChanges();

                    return(RedirectToAction("RegisterView"));
                }
                else
                {
                    ViewBag.Message = "Doğrulama başarısız..";
                }
                return(View(emp));


                //    if (ModelState.IsValid)
                //    {
                //        db.Employes.Add(emp);
                //        db.SaveChanges();
                //        return RedirectToAction("RegisterView");
                //        //doğrulama olduğu zaman yapılacak işlemler,yönlendirilecek sayfa vb.

                //    //doğrulama yapılmadığı takdirde ekrana aynı view getirilecek
                //    return View();
                //    db.Employes.Add(emp);
                //        db.SaveChanges();
                //        return RedirectToAction("RegisterView");


                //}
            }
        }
Beispiel #2
0
 public ActionResult Register(Emploies emp)
 {
     using (MyDbContext db = new MyDbContext())
     {
         db.Employes.Add(emp);
         db.SaveChanges();
         return(RedirectToAction("RegisterView"));
     }
 }
Beispiel #3
0
        public ActionResult GridViewPartial()
        {
            var      model = db.Appointmenties;
            Emploies aa    = db.Employes.Where(a => a.Id == 32).FirstOrDefault();

            ViewData["Appointments"] = aa.Fullname;


            return(PartialView("_GridViewPartial", model.ToList()));
        }
Beispiel #4
0
        public ActionResult RegisterEdit(Emploies UpdEmp)
        {
            MyDbContext db     = new MyDbContext();
            var         update = db.Employes.Where(a => a.Id == UpdEmp.Id).FirstOrDefault();

            update.Lastname  = UpdEmp.Lastname;
            update.Firstname = UpdEmp.Firstname;
            update.Adress    = UpdEmp.Adress;

            db.SaveChanges();
            return(RedirectToAction("RegisterView"));
        }
        public ActionResult RegisterDel(Emploies Deloper)
        {
            MyDbContext db = new MyDbContext();


            try
            {
                Emploies DelEmp = db.Employes.Where(o => o.Id == Deloper.Id).FirstOrDefault();
                db.Employes.Remove(DelEmp);
                db.SaveChanges();
                return(RedirectToAction("RegisterView"));
            }
            catch
            {
                return(View());
            }
        }
        public ActionResult GridViewPartialDelete([ModelBinder(typeof(DevExpressEditorsBinder))] rendevusistemi.Database.Data.Emploies DelEmp)
        {
            var model = db.Employes;

            if (DelEmp != null)
            {
                try
                {
                    Emploies Emp = db.Employes.Where(o => o.Id == DelEmp.Id).FirstOrDefault();
                    db.Employes.Remove(Emp);
                    db.SaveChanges();
                }
                catch (Exception e)
                {
                    ViewData["EditError"] = e.Message;
                }
            }
            return(PartialView("_GridViewPartial", model.ToList()));
        }