Пример #1
0
        public Reply DeleteEmployee([FromUri] int id)
        {
            Reply oR = new Reply
            {
                Result = 0
            };


            try
            {
                using (TriarioEntities1 db = new TriarioEntities1())
                {
                    int CC = id;
                    List <Search_Employee_Result> SearchEmployee = db.Search_Employee(CC).ToList();
                    if (SearchEmployee.Count() > 0)
                    {
                        int DeleteEmployee = db.Delete_Employee(CC);
                        oR.Data    = DeleteEmployee;
                        oR.Result  = 1;
                        oR.Message = "Borrado correctamente";
                    }
                    else
                    {
                        oR.Message = "Usuario no encontrado";
                    }
                }
            }
            catch (Exception)
            {
                oR.Message = "Error De Borrado";
            }

            return(oR);
        }
Пример #2
0
        public Reply Search([FromBody] EmployeeViewModel model)
        {
            Reply oR = new Reply
            {
                Result = 0
            };


            try
            {
                using (TriarioEntities1 db = new TriarioEntities1())
                {
                    List <Search_Employee_Result> SearchEmployee = db.Search_Employee(model.CC).ToList();
                    if (SearchEmployee.Count() > 0)
                    {
                        oR.Data   = SearchEmployee;
                        oR.Result = 1;
                    }
                    else
                    {
                        oR.Message = "Usuario Inexistente";
                    }
                }
            }
            catch (Exception)
            {
                oR.Message = "Error del servidor";
            }

            return(oR);
        }
Пример #3
0
        public Reply AlterEmployee([FromBody] EmployeeViewModel model)
        {
            Reply oR = new Reply
            {
                Result = 0
            };


            try
            {
                using (TriarioEntities1 db = new TriarioEntities1())
                {
                    List <Search_Employee_Result> SearchEmployee = db.Search_Employee(model.CC).ToList();
                    if (SearchEmployee.Count() > 0)
                    {
                        int AlterEmployee = db.Actualizate_Employee(model.CC, model.FName, model.LName, model.EUser, model.Email, model.Salary, model.Fk_Department);
                        oR.Data   = AlterEmployee;
                        oR.Result = 1;
                    }
                    else
                    {
                        oR.Message = "Usuario no encontrado";
                    }
                }
            }
            catch (Exception)
            {
                oR.Message = "Error De Actualizacion";
            }

            return(oR);
        }