Ejemplo n.º 1
0
 public static bool AddOrUpdate(SalaryLevel input)
 {
     try
     {
         using (var _context = new DBOLabManagementEntities())
         {
             _context.SalaryLevels.AddOrUpdate(input);
             _context.SaveChanges();
             return(true);
         }
     }
     catch (DbEntityValidationException e)
     {
         foreach (var eve in e.EntityValidationErrors)
         {
             foreach (var ve in eve.ValidationErrors)
             {
                 System.Windows.Forms.MessageBox.Show(ve.PropertyName.ToString() +
                                                      eve.Entry.CurrentValues.GetValue <object>(ve.PropertyName).ToString() +
                                                      ve.ErrorMessage.ToString());
             }
         }
         return(false);
     }
 }
Ejemplo n.º 2
0
        public IHttpActionResult PutSalaryLevel(int id, SalaryLevel SalaryLevel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != SalaryLevel.SalaryLevelID)
            {
                return(BadRequest());
            }

            db.Entry(SalaryLevel).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SalaryLevelExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Ejemplo n.º 3
0
        public IHttpActionResult GetSalaryLevel(int id)
        {
            SalaryLevel SalaryLevel = db.SalaryLevel.Find(id);

            if (SalaryLevel == null)
            {
                return(NotFound());
            }

            return(Ok(SalaryLevel));
        }
Ejemplo n.º 4
0
        public ActionResult Delete(int id)
        {
            SalaryLevel entity = db.SalaryLevel.FirstOrDefault(a => a.SalaryLevelID == id);

            if (entity != null)
            {
                db.SalaryLevel.Remove(entity);
                db.SaveChanges();
            }
            return(Json(new { Message = "Đã xóa thành công!" }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 5
0
 public JsonResult Edit(int Id, SalaryLevel data)
 {
     if (data != null)
     {
         data.SalaryLevelID   = Id;
         db.Entry(data).State = EntityState.Modified;
         db.SaveChanges();
         return(Json(new { Message = "Đã sửa thành công!" }, JsonRequestBehavior.AllowGet));
     }
     return(null);
 }
Ejemplo n.º 6
0
        public IHttpActionResult PostSalaryLevel(SalaryLevel SalaryLevel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.SalaryLevel.Add(SalaryLevel);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = SalaryLevel.SalaryLevelID }, SalaryLevel));
        }
Ejemplo n.º 7
0
        public IHttpActionResult DeleteSalaryLevel(int id)
        {
            SalaryLevel SalaryLevel = db.SalaryLevel.Find(id);

            if (SalaryLevel == null)
            {
                return(NotFound());
            }

            db.SalaryLevel.Remove(SalaryLevel);
            db.SaveChanges();

            return(Ok(SalaryLevel));
        }
Ejemplo n.º 8
0
 public JsonResult Create(SalaryLevel data)
 {
     db.SalaryLevel.Add(data);
     db.SaveChanges();
     return(Json(new { Message = "Đã thêm thành công!" }, JsonRequestBehavior.AllowGet));
 }