Exemplo n.º 1
0
        public tblCalisan AddOrUpdate(tblCalisan entity)
        {
            try
            {
                _db.Entry(entity).State = entity.ID == 0 ?
                                          EntityState.Added :
                                          EntityState.Modified;
                _db.SaveChanges();
            }
            catch (DbEntityValidationException e)
            {
                foreach (var eve in e.EntityValidationErrors)
                {
                    Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                      eve.Entry.Entity.GetType().Name, eve.Entry.State);
                    foreach (var ve in eve.ValidationErrors)
                    {
                        Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                          ve.PropertyName, ve.ErrorMessage);
                    }
                }
                throw;
            }


            return(entity);
        }
Exemplo n.º 2
0
 public ActionResult Edit([Bind(Include = "CalisanID,Ad,Soyad,Telefon,Departman,Yonetici")] tblCalisan tblCalisan)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tblCalisan).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Yonetici  = new SelectList(db.tblCalisan, "CalisanID", "Ad", tblCalisan.Yonetici);
     ViewBag.Departman = new SelectList(db.tblDepartman, "DepartmanID", "DepartmanAd", tblCalisan.Departman);
     return(View(tblCalisan));
 }
Exemplo n.º 3
0
        // GET: Calisan/CalisanDetay/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(View());
            }
            tblCalisan tblCalisan = db.tblCalisan.Find(id);

            if (tblCalisan == null)
            {
                return(HttpNotFound());
            }
            return(View(tblCalisan));
        }
Exemplo n.º 4
0
        // GET: Calisan/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(View());
            }
            tblCalisan tblCalisan = db.tblCalisan.Find(id);

            if (tblCalisan == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Yonetici  = new SelectList(db.tblCalisan, "CalisanID", "Ad", tblCalisan.Yonetici);
            ViewBag.Departman = new SelectList(db.tblDepartman, "DepartmanID", "DepartmanAd", tblCalisan.Departman);
            return(View(tblCalisan));
        }
Exemplo n.º 5
0
        public ActionResult DeleteConfirmed(int id)
        {
            tblCalisan tblCalisan = db.tblCalisan.Find(id);
            var        Yonetici   = (from m in db.tblCalisan
                                     where m.Yonetici == id
                                     select m).FirstOrDefault();

            if (Yonetici == null)
            {
                db.tblCalisan.Remove(tblCalisan);
                db.SaveChanges();
            }
            else
            {
                ViewBag.Message = "Çalışan Aynı zamanda bir yönetici ise çalışanı silemezsiniz. İlk önce Çalışanları Başka bir yöneticiye taşıyın.";
                return(View());
            }
            return(RedirectToAction("Index"));
        }
Exemplo n.º 6
0
 public void Update(tblCalisan entity)
 {
     _db.Entry(entity).State = EntityState.Modified;
     _db.SaveChanges();
 }
Exemplo n.º 7
0
 public void Delete(tblCalisan entity)
 {
     _db.tblCalisan.Remove(entity);
     _db.SaveChanges();
 }
Exemplo n.º 8
0
 public void Add(tblCalisan entity)
 {
     _db.tblCalisan.Add(entity);
     _db.SaveChanges();
 }