Пример #1
0
        public HttpResponseMessage UpdateEmployed(TLSEmpleado employed)
        {
            var transaction = db.Database.BeginTransaction();

            try
            {
                var update = db.UpdateEmpleados(employed.Nombre, employed.Apellido, employed.Email, employed.Cedula, employed.Fecha, employed.IdDepartamento, employed.Puesto, employed.Horario, employed.Sueldo, employed.Perfil);
                db.InsertLogs(EnumLevelLogs.DEBUG.ToString(), $"{update} row update", $"{EnumLevelLogs.DEBUG}");
                var ok = db.SaveChanges();
                transaction.Commit();
                return(Request.CreateResponse(HttpStatusCode.Accepted, "the employed is update"));
            }
            catch (Exception ex)
            {
                db.InsertLogs(EnumLevelLogs.ERROR.ToString(), $" Employed 0 row update", $"{ex.Message}");
                transaction.Rollback();
                return(Request.CreateResponse(HttpStatusCode.ExpectationFailed, $"{ex.Message}"));
            }
        }
Пример #2
0
        public IHttpActionResult GetIDEmployed(int cedula)
        {
            TLSEmpleado cliente = null;

            try
            {
                cliente = db.TLSEmpleadoes.ToList().Find(e => e.Cedula == cedula);
            }
            catch (Exception)
            {
                db.InsertLogs(EnumLevelLogs.DEBUG.ToString(), $" Employed not fount", $"{EnumLevelLogs.DEBUG}");
            }
            if (cliente != null)
            {
                var json = Newtonsoft.Json.JsonConvert.SerializeObject(User);
                db.InsertLogs(EnumLevelLogs.DEBUG.ToString(), $" Employed {cliente.Cedula} found", $"{EnumLevelLogs.DEBUG}");
                return(Json(json));
            }
            return(Ok("No employed found"));
        }