コード例 #1
0
        /// <summary>
        /// Obtener Periodo Facturación
        /// </summary>
        /// <returns>Lista de Periodo Facturación</returns>
        public MethodResponseDTO <List <C_PeriodosDTO> > ObtenerPeriodo()
        {
            using (var context = new DB_9F97CF_CatarsysSGCEntities())
            {
                try
                {
                    var response = new MethodResponseDTO <List <C_PeriodosDTO> >()
                    {
                        Code = 0
                    };


                    var obj = context.C_Periodos.ToList();

                    response.Result = Mapper.Map <List <C_PeriodosDTO> >(obj);

                    return(response);
                }
                catch (Exception ex)
                {
                    return(new MethodResponseDTO <List <C_PeriodosDTO> > {
                        Code = -100, Message = "ObtenerPeriodo: " + ex.Message
                    });
                }
            }
        }
コード例 #2
0
        public MethodResponseDTO <List <ContactosDTO> > GetContactosCliente(int IdCliente)
        {
            using (var context = new DB_9F97CF_CatarsysSGCEntities())
            {
                try
                {
                    var response = new MethodResponseDTO <List <ContactosDTO> >()
                    {
                        Code = 0
                    };


                    var clientes = context.Contactos.Where(x => x.Id_Cliente == IdCliente && x.Estado == true).ToList();

                    response.Result = Mapper.Map <List <ContactosDTO> >(clientes);

                    return(response);
                }
                catch (Exception ex)
                {
                    return(new MethodResponseDTO <List <ContactosDTO> > {
                        Code = -100, Message = "ObtenerContactos: " + ex.Message
                    });
                }
            }
        }
コード例 #3
0
 public MethodResponseDTO <string> GenerateHMAC(string clearMessage, string secretKeyString)
 {
     try
     {
         var response = new MethodResponseDTO <string>()
         {
             Code = 0
         };
         var encoder        = new ASCIIEncoding();
         var messageBytes   = encoder.GetBytes(clearMessage);
         var secretKeyBytes = new byte[secretKeyString.Length / 2];
         for (int index = 0; index < secretKeyBytes.Length; index++)
         {
             string byteValue = secretKeyString.Substring(index * 2, 2);
             secretKeyBytes[index] = byte.Parse(byteValue, NumberStyles.HexNumber, CultureInfo.InvariantCulture);
         }
         var    hmacsha512 = new HMACSHA512(secretKeyBytes);
         byte[] hashValue  = hmacsha512.ComputeHash(messageBytes);
         string hmac       = "";
         foreach (byte x in hashValue)
         {
             hmac += String.Format("{0:x2}", x);
         }
         response.Result = hmac.ToUpper();
         return(response);
     }
     catch (Exception ex)
     {
         //Logger.Error("Code: -200 Mensaje: " + ex.Message + ", InnerException: " + (ex.InnerException != null ? ex.InnerException.Message : ""), ex);
         return(new MethodResponseDTO <string> {
             Code = -200, Message = ex.Message
         });
     }
 }
コード例 #4
0
ファイル: FrasesData.cs プロジェクト: mugauli/Blablabla_Sln
        public MethodResponseDTO <List <fraseDTO> > ObtenerFrases()
        {
            try
            {
                var response = new MethodResponseDTO <List <fraseDTO> > {
                    Code = 0
                };
                using (var context = new BlablablaSitioEntities())
                {
                    var DbFrasesLts = context.ctFrases.Where(x => x.estado == true).
                                      Select(x => new fraseDTO
                    {
                        Id       = x.Id,
                        enun1    = x.enun1,
                        enun2    = x.enun2,
                        correcta = x.correcta,
                        opcion1  = x.opcion1,
                        opcion2  = x.opcion2,
                        opcion3  = x.opcion3
                    }).ToList();

                    response.Result = DbFrasesLts;
                }
                return(response);
            }
            catch (Exception ex)
            {
                return(new MethodResponseDTO <List <fraseDTO> > {
                    Code = -100, Message = ex.Message
                });
            }
        }
コード例 #5
0
        /// <summary>
        /// Obtener Empleados por username
        /// </summary>
        /// <param name="Username"></param>
        /// <returns>EmpleadosDTO</returns>
        public MethodResponseDTO <EmpleadosDTO> ObtenerEmpleados(string Username)
        {
            using (var context = new DB_9F97CF_CatarsysSGCEntities())
            {
                try
                {
                    var response = new MethodResponseDTO <EmpleadosDTO>()
                    {
                        Code = 0
                    };


                    var clientes = context.Empleados.Where(x => x.Usuario_Empleado == Username).FirstOrDefault();

                    response.Result = Mapper.Map <EmpleadosDTO>(clientes);

                    return(response);
                }
                catch (Exception ex)
                {
                    return(new MethodResponseDTO <EmpleadosDTO> {
                        Code = -100, Message = "ObtenerEmpleados: " + ex.Message
                    });
                }
            }
        }
コード例 #6
0
        /// <summary>
        /// Obtener Empresas ->
        /// Con IdEmpresa = 0 regresara todas las Empresas
        /// Con Estado = 2 regresara todas las Empresas de todos los estados
        /// </summary>
        /// <param name="IdEmpresa"></param>
        /// <param name="Estado"></param>
        /// <returns></returns>
        public MethodResponseDTO <List <EmpresaDTO> > ObtenerEmpresas(int Id_Empresa, int Estado)
        {
            using (var context = new DB_9F97CF_CatarsysSGCEntities())
            {
                try
                {
                    var response = new MethodResponseDTO <List <EmpresaDTO> >()
                    {
                        Code = 0
                    };


                    var obj = context.Empresa.Where(x => (x.Id_Empresa == Id_Empresa || Id_Empresa == 0) &&
                                                    (x.Estado_Empresa == (Estado == 1) || Estado == 2)).ToList();

                    response.Result = Mapper.Map <List <EmpresaDTO> >(obj);

                    return(response);
                }
                catch (Exception ex)
                {
                    return(new MethodResponseDTO <List <EmpresaDTO> > {
                        Code = -100, Message = "ObtenerEmpleados: " + ex.Message
                    });
                }
            }
        }
コード例 #7
0
        /// <summary>
        /// Obtener Proyectos
        /// Con IdProyecto = 0 regresara todos los proyectos
        /// Con IdEmpresa = 0 regresara todos los proyectos de todas las empresas
        /// Con estado =  0 regresara los proyectos de cualquier estado
        /// </summary>
        /// <param name="idProyecto"></param>
        /// <param name="idEmpresa"></param>
        /// <param name="estado"></param>
        /// <returns>Lista de proyectos</returns>
        public MethodResponseDTO <List <ProyectosDTO> > ObtenerProyecto(int idProyecto, int idEmpresa, int estado)
        {
            using (var context = new DB_9F97CF_CatarsysSGCEntities())
            {
                try
                {
                    var response = new MethodResponseDTO <List <ProyectosDTO> >()
                    {
                        Code = 0
                    };


                    var asignaciones = context.Proyectos.Where(x => (x.Id_Proyectos == idProyecto || idProyecto == 0) &&
                                                               (x.Estado == (estado == 1) || estado == 2) &&
                                                               (x.Id_Empresa == idEmpresa || idEmpresa == 0)).ToList();
                    response.Result = Mapper.Map <List <ProyectosDTO> >(asignaciones);

                    return(response);
                }
                catch (Exception ex)
                {
                    return(new MethodResponseDTO <List <ProyectosDTO> > {
                        Code = -100, Message = "ObtenerProyecto: " + ex.Message
                    });
                }
            }
        }
コード例 #8
0
        /// <summary>
        /// Obtener Asignaciones
        /// Con idAsignacion = 0 regresara todas las asignaciones
        /// Con estatusAsignacion =  0 regresara las asignaciones de cualquier estado
        /// </summary>
        /// <param name="idAsignacion"></param>
        /// <param name="estatusAsignacion"></param>
        /// <returns></returns>
        public MethodResponseDTO <List <AsignacionDTO> > ObtenerAsignaciones(int idAsignacion, int estatusAsignacion)
        {
            using (var context = new DB_9F97CF_CatarsysSGCEntities())
            {
                try
                {
                    var response = new MethodResponseDTO <List <AsignacionDTO> >()
                    {
                        Code = 0
                    };


                    var asignaciones = context.Asignacion.Where(x => (x.Id_Asignacion == idAsignacion || idAsignacion == 0) && (x.Id_Estatus_Asignacion == estatusAsignacion || estatusAsignacion == 0)).ToList();
                    response.Result = Mapper.Map <List <AsignacionDTO> >(asignaciones);

                    return(response);
                }
                catch (Exception ex)
                {
                    return(new MethodResponseDTO <List <AsignacionDTO> > {
                        Code = -100, Message = "ObtenerAsignaciones: " + ex.Message
                    });
                }
            }
        }
コード例 #9
0
        public MethodResponseDTO <PaginacionDTO <List <AsignacionPaginadorDTO> > > ObtenerAsignacionesPaginacion(int page, int size, int sort, string sortDireccion, string filter, int Id_Empresa)
        {
            using (var context = new DB_9F97CF_CatarsysSGCEntities())
            {
                try
                {
                    var response = new MethodResponseDTO <PaginacionDTO <List <AsignacionPaginadorDTO> > >()
                    {
                        Code = 0
                    };

                    var responsePag = new PaginacionDTO <List <AsignacionPaginadorDTO> >();


                    ObjectParameter totalrow   = new ObjectParameter("totalrow", typeof(int));
                    var             asignacion = context.sp_GetAsigPaginacion(page, size, sort, Id_Empresa, sortDireccion, filter, totalrow).ToList();


                    responsePag.data         = Mapper.Map <List <AsignacionPaginadorDTO> >(asignacion);
                    responsePag.recordsTotal = Convert.ToInt32(totalrow.Value);
                    responsePag.draw         = page;

                    response.Result = responsePag;
                    return(response);
                }
                catch (Exception ex)
                {
                    return(new MethodResponseDTO <PaginacionDTO <List <AsignacionPaginadorDTO> > > {
                        Code = -100, Message = "ObtenerAsignaciones: " + ex.Message
                    });
                }
            }
        }
コード例 #10
0
        /// <summary>
        /// Obtener Asignaciones
        /// Con idAsignacion = 0 regresara todas las asignaciones
        /// Con estatusAsignacion =  0 regresara las asignaciones de cualquier estado
        /// </summary>
        /// <param name="idFactura"></param>
        /// <param name="estatusAsignacion"></param>
        /// <returns></returns>
        public MethodResponseDTO <List <FacturasDTO> > ObtenerFacturas(int idFactura)
        {
            using (var context = new DB_9F97CF_CatarsysSGCEntities())
            {
                try
                {
                    var response = new MethodResponseDTO <List <FacturasDTO> >()
                    {
                        Code = 0
                    };


                    var asignaciones = context.Facturas.Where(x => (x.IdFactura == idFactura || idFactura == 0)).ToList();
                    response.Result = Mapper.Map <List <FacturasDTO> >(asignaciones);

                    return(response);
                }
                catch (Exception ex)
                {
                    return(new MethodResponseDTO <List <FacturasDTO> > {
                        Code = -100, Message = "ObtenerAsignaciones: " + ex.Message
                    });
                }
            }
        }
コード例 #11
0
        public MethodResponseDTO <PaginacionDTO <List <CarteraVencidaPaginadorDTO> > > ObtenerCarteraVencidaPaginacion(int page, int size, int sort, string sortDireccion, string filter, int filterCliente, int filterEstado, DateTime filterPeriodo, int Id_Empresa)
        {
            using (var context = new DB_9F97CF_CatarsysSGCEntities())
            {
                try
                {
                    var response = new MethodResponseDTO <PaginacionDTO <List <CarteraVencidaPaginadorDTO> > >()
                    {
                        Code = 0
                    };

                    var responsePag = new PaginacionDTO <List <CarteraVencidaPaginadorDTO> >();


                    ObjectParameter totalrow   = new ObjectParameter("totalrow", typeof(int));
                    var             asignacion = context.sp_GetCarteraVencidaPaginacion(page, size, sort, Id_Empresa, sortDireccion, filter, filterEstado, filterPeriodo, totalrow).ToList();
                    //var asignacion = context.sp_GetCarteraVencidaPaginacion(0, 10, 1, 1, "asc", "",1, filterPeriodo, totalrow).ToList();

                    responsePag.data         = Mapper.Map <List <CarteraVencidaPaginadorDTO> >(asignacion);
                    responsePag.recordsTotal = Convert.ToInt32(totalrow.Value);
                    responsePag.draw         = page;

                    response.Result = responsePag;
                    return(response);
                }
                catch (Exception ex)
                {
                    return(new MethodResponseDTO <PaginacionDTO <List <CarteraVencidaPaginadorDTO> > > {
                        Code = -100, Message = "Obtner Facturas Paginador: " + ex.Message
                    });
                }
            }
        }
コード例 #12
0
        /// <summary>
        /// Obtener Tipo Asignación
        /// </summary>
        /// <returns>Lista de tipo asignacion</returns>
        public MethodResponseDTO <List <C_Tipo_AsignacionDTO> > ObtenerTipoAsignacion()
        {
            using (var context = new DB_9F97CF_CatarsysSGCEntities())
            {
                try
                {
                    var response = new MethodResponseDTO <List <C_Tipo_AsignacionDTO> >()
                    {
                        Code = 0
                    };


                    var tipoAsignacion = context.C_Tipo_Asignacion.ToList();

                    response.Result = Mapper.Map <List <C_Tipo_AsignacionDTO> >(tipoAsignacion);

                    return(response);
                }
                catch (Exception ex)
                {
                    return(new MethodResponseDTO <List <C_Tipo_AsignacionDTO> > {
                        Code = -100, Message = "ObtenerTipoAsignacion: " + ex.Message
                    });
                }
            }
        }
コード例 #13
0
        /// <summary>
        /// Obtener Permisos
        /// </summary>
        /// <returns>Lista de tipo asignacion</returns>
        public MethodResponseDTO <List <PermisosDTO> > ObtenerPermisos()
        {
            using (var context = new DB_9F97CF_CatarsysSGCEntities())
            {
                try
                {
                    var response = new MethodResponseDTO <List <PermisosDTO> >()
                    {
                        Code = 0
                    };


                    var tipoAsignacion = context.ctPermisos.Where(x => x.Estado_Permiso == true).ToList();

                    response.Result = Mapper.Map <List <PermisosDTO> >(tipoAsignacion);

                    return(response);
                }
                catch (Exception ex)
                {
                    return(new MethodResponseDTO <List <PermisosDTO> > {
                        Code = -100, Message = "Obtener Permisos DTO: " + ex.Message
                    });
                }
            }
        }
コード例 #14
0
        /// <summary>
        /// Obtener Metodo de Pago
        /// </summary>
        /// <returns>Lista de tipo asignacion</returns>
        public MethodResponseDTO <List <C_Metodo_PagoDTO> > ObtenerMetodoPago()
        {
            using (var context = new DB_9F97CF_CatarsysSGCEntities())
            {
                try
                {
                    var response = new MethodResponseDTO <List <C_Metodo_PagoDTO> >()
                    {
                        Code = 0
                    };


                    var metodoPago = context.C_Metodo_Pago.ToList();

                    response.Result = Mapper.Map <List <C_Metodo_PagoDTO> >(metodoPago);

                    return(response);
                }
                catch (Exception ex)
                {
                    return(new MethodResponseDTO <List <C_Metodo_PagoDTO> > {
                        Code = -100, Message = "Obtener Metodo Pago DTO: " + ex.Message
                    });
                }
            }
        }
コード例 #15
0
        public MethodResponseDTO <string> CreateSalt512()
        {
            try
            {
                var response = new MethodResponseDTO <string>()
                {
                    Code = 0
                };

                var respRanStr = RandomString(512, false);
                if (respRanStr.Code < 0)
                {
                    response.Code    = respRanStr.Code;
                    response.Message = respRanStr.Message;
                    return(response);
                }
                var message = respRanStr.Result;
                response.Result = BitConverter.ToString((new SHA512Managed()).ComputeHash(Encoding.ASCII.GetBytes(message))).Replace("-", "");
                return(response);
            }
            catch (Exception ex)
            {
                //Logger.Error("Code: -200 Mensaje: " + ex.Message + ", InnerException: " + (ex.InnerException != null ? ex.InnerException.Message : ""), ex);
                return(new MethodResponseDTO <string> {
                    Code = -200, Message = ex.Message
                });
            }
        }
コード例 #16
0
        public MethodResponseDTO <string> RandomString(int size, bool lowerCase)
        {
            try
            {
                var response = new MethodResponseDTO <string>()
                {
                    Code = 0
                };

                var builder = new StringBuilder();
                var random  = new Random();
                for (int i = 0; i < size; i++)
                {
                    char ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65)));
                    builder.Append(ch);
                }
                response.Result = lowerCase ? builder.ToString().ToLower() : builder.ToString();
                return(response);
            }
            catch (Exception ex)
            {
                //Logger.Error("Code: -200 Mensaje: " + ex.Message + ", InnerException: " + (ex.InnerException != null ? ex.InnerException.Message : ""), ex);
                return(new MethodResponseDTO <string> {
                    Code = -200, Message = ex.Message
                });
            }
        }
コード例 #17
0
        public MethodResponseDTO <int> GuardarContactos(ContactosDTO contactos)
        {
            using (var context = new DB_9F97CF_CatarsysSGCEntities())
            {
                try
                {
                    var response = new MethodResponseDTO <int>()
                    {
                        Code = 0, Result = 1
                    };


                    if (contactos.Id_Contacto == 0)
                    {
                        var objDB = Mapper.Map <Contactos>(contactos);
                        context.Contactos.Add(objDB);
                    }
                    else
                    {
                        var objDB = context.Contactos.SingleOrDefault(x => x.Id_Contacto == contactos.Id_Contacto);

                        objDB.Nombre_Contacto       = contactos.Nombre_Contacto;
                        objDB.Puesto_Contacto       = contactos.Puesto_Contacto;
                        objDB.Email_Contacto        = contactos.Email_Contacto;
                        objDB.Telefono_Contacto     = contactos.Telefono_Contacto;
                        objDB.Movil__Contacto       = contactos.Movil__Contacto;
                        objDB.Skype_Contacto        = contactos.Skype_Contacto;
                        objDB.Comentario_Contacto   = contactos.Comentario_Contacto;
                        objDB.EnviaFactura_Contacto = contactos.EnviaFactura_Contacto;
                        objDB.Estado = contactos.Estado;
                    }
                    context.SaveChanges();

                    return(response);
                }
                catch (DbEntityValidationException e)
                {
                    string Result = string.Empty;
                    foreach (var eve in e.EntityValidationErrors)
                    {
                        Result += string.Format("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)
                        {
                            Result += string.Format("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage);
                        }
                    }
                    Result += ("Code: -100, Mensaje: " + e.Message + ", InnerException: " + (e.InnerException != null ? e.InnerException.Message : ""));
                    return(new MethodResponseDTO <int> {
                        Code = -100, Result = 0, Message = e.Message
                    });
                }
                catch (Exception ex)
                {
                    return(new MethodResponseDTO <int> {
                        Code = -100, Result = 0, Message = "GuardarAsignacion: " + ex.Message
                    });
                }
            }
        }
コード例 #18
0
ファイル: FrasesData.cs プロジェクト: mugauli/Blablabla_Sln
        public MethodResponseDTO <bool> GuardarFrases(List <fraseDTO> frases)
        {
            try
            {
                var response = new MethodResponseDTO <bool> {
                    Code = 0
                };
                using (var context = new BlablablaSitioEntities())
                {
                    var DbFrasesLts = context.ctFrases.ToList();

                    foreach (var objFrase in frases)
                    {
                        var frase = DbFrasesLts.Where(x => x.Id == objFrase.Id).ToList();

                        if (frase.Count > 0)
                        {
                            var DbFrase = context.ctFrases.Find(objFrase.Id);
                            DbFrase.enun1    = objFrase.enun1;
                            DbFrase.enun2    = objFrase.enun2;
                            DbFrase.correcta = objFrase.correcta;
                            DbFrase.opcion1  = objFrase.opcion1;
                            DbFrase.opcion2  = objFrase.opcion2;
                            DbFrase.opcion3  = objFrase.opcion3;
                            DbFrase.estado   = true;
                            context.SaveChanges();
                        }
                        else
                        {
                            var objCtFrase = new ctFrases
                            {
                                Id       = objFrase.Id,
                                enun1    = objFrase.enun1,
                                enun2    = objFrase.enun2,
                                correcta = objFrase.correcta,
                                opcion1  = objFrase.opcion1,
                                opcion2  = objFrase.opcion2,
                                opcion3  = objFrase.opcion3,
                                estado   = true
                            };
                            context.ctFrases.Add(objCtFrase);
                            context.SaveChanges();
                        }

                        context.SaveChanges();
                    }
                }

                return(response);
            }
            catch (Exception ex)
            {
                return(new MethodResponseDTO <bool> {
                    Code = -100, Message = ex.Message
                });
            }
        }
コード例 #19
0
        /// <summary>
        /// Guardar Asignacion
        /// </summary>
        /// <returns>Lista de tipo asignacion</returns>
        public MethodResponseDTO <int> GuardarPermisos(List <EmpleadoPermisoDTO> permisos)
        {
            using (var context = new DB_9F97CF_CatarsysSGCEntities())
            {
                try
                {
                    var response = new MethodResponseDTO <int>()
                    {
                        Code = 0, Result = 1
                    };

                    foreach (var perm in permisos)
                    {
                        var objDB = context.EmpleadoPermiso.Where(x => x.Id_Empleado == perm.Id_Empleado && perm.Id_Permiso == x.Id_Permiso).FirstOrDefault();
                        if (objDB == null)
                        {
                            objDB = Mapper.Map <EmpleadoPermiso>(perm);
                            context.EmpleadoPermiso.Add(objDB);
                        }
                        else
                        {
                            objDB.Id_Empleado  = perm.Id_Empleado;
                            objDB.Id_Permiso   = perm.Id_Permiso;
                            objDB.Tipo_Permiso = perm.Tipo_Permiso;
                        }
                        context.SaveChanges();
                    }

                    return(response);
                }
                catch (DbEntityValidationException e)
                {
                    string Result = string.Empty;
                    foreach (var eve in e.EntityValidationErrors)
                    {
                        Result += string.Format("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)
                        {
                            Result += string.Format("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage);
                        }
                    }
                    Result += ("Code: -100, Mensaje: " + e.Message + ", InnerException: " + (e.InnerException != null ? e.InnerException.Message : ""));
                    return(new MethodResponseDTO <int> {
                        Code = -100, Result = 0, Message = e.Message
                    });
                }
                catch (Exception ex)
                {
                    return(new MethodResponseDTO <int> {
                        Code = -100, Result = 0, Message = "GuardarAsignacion: " + ex.Message
                    });
                }
            }
        }
コード例 #20
0
        /// <summary>
        /// Borrar Facturas
        /// </summary>
        /// <returns>Lista de tipo asignacion</returns>
        public MethodResponseDTO <int> BorrarFacturas(int Id, int tipo)
        {
            using (var context = new DB_9F97CF_CatarsysSGCEntities())
            {
                try
                {
                    var response = new MethodResponseDTO <int>()
                    {
                        Code = 0, Result = 1
                    };

                    List <Facturas> ltsFacturas;
                    if (tipo == 1)
                    {
                        ltsFacturas = context.Facturas.Where(x => x.IdProyecto == Id && x.Id_Estado_Factura == 1).ToList();
                    }
                    else
                    {
                        ltsFacturas = context.Facturas.Where(x => x.IdAsignacion == Id && x.Id_Estado_Factura == 1).ToList();
                    }

                    foreach (var factura in ltsFacturas)
                    {
                        context.Facturas.Remove(factura);
                        context.SaveChanges();
                    }

                    return(response);
                }
                catch (DbEntityValidationException e)
                {
                    string Result = string.Empty;
                    foreach (var eve in e.EntityValidationErrors)
                    {
                        Result += string.Format("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)
                        {
                            Result += string.Format("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage);
                        }
                    }
                    Result += ("Code: -100, Mensaje: " + e.Message + ", InnerException: " + (e.InnerException != null ? e.InnerException.Message : ""));
                    return(new MethodResponseDTO <int> {
                        Code = -100, Result = 0, Message = e.Message
                    });
                }
                catch (Exception ex)
                {
                    return(new MethodResponseDTO <int> {
                        Code = -100, Result = 0, Message = "GuardarAsignacion: " + ex.Message
                    });
                }
            }
        }
コード例 #21
0
ファイル: FrasesData.cs プロジェクト: mugauli/Blablabla_Sln
        public MethodResponseDTO <bool> BorrarFrase(int idfrase, int tipo)
        {
            try
            {
                var response = new MethodResponseDTO <bool> {
                    Code = 0
                };
                using (var context = new BlablablaSitioEntities())
                {
                    if (tipo == 1)
                    {
                        var DbFrase = context.ctFrases.Find(idfrase);

                        if (DbFrase != null)
                        {
                            DbFrase.estado = false;
                            context.SaveChanges();
                        }
                        else
                        {
                            response.Code    = -800;
                            response.Message = "La frase que desa borrar no existe.";
                        }
                    }
                    else
                    {
                        var DbFrase = context.ctFrasesSilabitos.Find(idfrase);

                        if (DbFrase != null)
                        {
                            DbFrase.estado = false;
                            context.SaveChanges();
                        }
                        else
                        {
                            response.Code    = -800;
                            response.Message = "La frase que desa borrar no existe.";
                        }
                    }
                    context.SaveChanges();
                }

                return(response);
            }
            catch (Exception ex)
            {
                return(new MethodResponseDTO <bool> {
                    Code = -100, Message = ex.Message
                });
            }
        }
コード例 #22
0
ファイル: FrasesData.cs プロジェクト: mugauli/Blablabla_Sln
        public MethodResponseDTO <bool> GuardarFrase(fraseDTO frase)
        {
            try
            {
                var response = new MethodResponseDTO <bool> {
                    Code = 0
                };
                using (var context = new BlablablaSitioEntities())
                {
                    var DbFrase = context.ctFrases.Find(frase.Id);

                    if (DbFrase != null)
                    {
                        DbFrase.enun1    = frase.enun1;
                        DbFrase.enun2    = frase.enun2;
                        DbFrase.correcta = frase.correcta;
                        DbFrase.opcion1  = frase.opcion1;
                        DbFrase.opcion2  = frase.opcion2;
                        DbFrase.opcion3  = frase.opcion3;
                        DbFrase.estado   = true;
                        context.SaveChanges();
                    }
                    else
                    {
                        var objCtFrase = new ctFrases
                        {
                            Id       = frase.Id,
                            enun1    = frase.enun1,
                            enun2    = frase.enun2,
                            correcta = frase.correcta,
                            opcion1  = frase.opcion1,
                            opcion2  = frase.opcion2,
                            opcion3  = frase.opcion3,
                            estado   = true
                        };
                        context.ctFrases.Add(objCtFrase);
                    }

                    context.SaveChanges();
                }

                return(response);
            }
            catch (Exception ex)
            {
                return(new MethodResponseDTO <bool> {
                    Code = -100, Message = ex.Message
                });
            }
        }
コード例 #23
0
        public MethodResponseDTO <EmpleadoPermisoDTO> ObtenRolActivo(int IdPermiso)
        {
            using (var context = new DB_9F97CF_CatarsysSGCEntities())
            {
                try
                {
                    var response = new MethodResponseDTO <EmpleadoPermisoDTO> {
                        Code = 0
                    };


                    var objDB = context.ctPermisos.SingleOrDefault(r => r.Id_Permisos == IdPermiso && r.Estado_Permiso == true);

                    if (objDB != null)
                    {
                        response.Result = Mapper.Map <EmpleadoPermisoDTO>(objDB);
                    }

                    return(response);
                }
                catch (DbEntityValidationException e)
                {
                    string Result = string.Empty;
                    foreach (var eve in e.EntityValidationErrors)
                    {
                        Result += string.Format("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)
                        {
                            Result += string.Format("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage);
                        }
                    }
                    Result += ("Code: -100, Mensaje: " + e.Message + ", InnerException: " + (e.InnerException != null ? e.InnerException.Message : ""));
                    return(new MethodResponseDTO <EmpleadoPermisoDTO> {
                        Code = -100, Message = Result
                    });
                }
                catch (Exception ex)
                {
                    return(new MethodResponseDTO <EmpleadoPermisoDTO> {
                        Code = -100, Message = "GuardarAsignacion: " + ex.Message
                    });
                }
            }
        }
コード例 #24
0
        public MethodResponseDTO <bool> ObtenerPermisosTipo(int IdEmpleado, int Idpermiso)
        {
            using (var context = new DB_9F97CF_CatarsysSGCEntities())
            {
                try
                {
                    var response = new MethodResponseDTO <bool> {
                        Code = 0
                    };


                    var objDB = context.EmpleadoPermiso.Where(a => a.Id_Empleado == IdEmpleado && a.Id_Permiso == Idpermiso).FirstOrDefault();



                    response.Result = (objDB.Tipo_Permiso == 2 || objDB.Tipo_Permiso == 3);

                    return(response);
                }
                catch (DbEntityValidationException e)
                {
                    string Result = string.Empty;
                    foreach (var eve in e.EntityValidationErrors)
                    {
                        Result += string.Format("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)
                        {
                            Result += string.Format("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage);
                        }
                    }
                    Result += ("Code: -100, Mensaje: " + e.Message + ", InnerException: " + (e.InnerException != null ? e.InnerException.Message : ""));
                    return(new MethodResponseDTO <bool> {
                        Code = -100, Message = Result
                    });
                }
                catch (Exception ex)
                {
                    return(new MethodResponseDTO <bool> {
                        Code = -100, Message = "Obtener permiso Tipo: " + ex.Message
                    });
                }
            }
        }
コード例 #25
0
        public MethodResponseDTO <List <EmpleadoPermisoDTO> > ObtenerPermisos(int IdEmpleado)
        {
            using (var context = new DB_9F97CF_CatarsysSGCEntities())
            {
                try
                {
                    var response = new MethodResponseDTO <List <EmpleadoPermisoDTO> > {
                        Code = 0
                    };


                    var objDB = context.EmpleadoPermiso
                                .Join(context.ctPermisos, c => c.Id_Permiso, cm => cm.Id_Permisos, (c, cm) => new { EmpPer = c, Per = cm })
                                .Where(a => a.EmpPer.Id_Empleado == IdEmpleado && a.Per.Estado_Permiso == true && a.EmpPer.Tipo_Permiso > 0).Select(x => x.EmpPer);

                    response.Result = Mapper.Map <List <EmpleadoPermisoDTO> >(objDB);

                    return(response);
                }
                catch (DbEntityValidationException e)
                {
                    string Result = string.Empty;
                    foreach (var eve in e.EntityValidationErrors)
                    {
                        Result += string.Format("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)
                        {
                            Result += string.Format("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage);
                        }
                    }
                    Result += ("Code: -100, Mensaje: " + e.Message + ", InnerException: " + (e.InnerException != null ? e.InnerException.Message : ""));
                    return(new MethodResponseDTO <List <EmpleadoPermisoDTO> > {
                        Code = -100, Message = Result
                    });
                }
                catch (Exception ex)
                {
                    return(new MethodResponseDTO <List <EmpleadoPermisoDTO> > {
                        Code = -100, Message = "GuardarAsignacion: " + ex.Message
                    });
                }
            }
        }
コード例 #26
0
        /// <summary>
        /// Guardar Empleado
        /// </summary>
        /// <returns>Lista de tipo asignacion</returns>
        public MethodResponseDTO <int> GuardarEmpleado(EmpleadosDTO empleado)
        {
            using (var context = new DB_9F97CF_CatarsysSGCEntities())
            {
                try
                {
                    var response = new MethodResponseDTO <int>()
                    {
                        Code = 0, Result = 1
                    };


                    if (empleado.Id_Empleado == 0)
                    {
                        var objDB = Mapper.Map <Empleados>(empleado);
                        context.Empleados.Add(objDB);
                    }
                    else
                    {
                        var objDB = context.Empleados.SingleOrDefault(x => x.Id_Empleado == empleado.Id_Empleado);

                        objDB.Id_Empleado               = empleado.Id_Empleado;
                        objDB.Id_Empresa                = empleado.Id_Empresa;
                        objDB.Nombre_Empleado           = empleado.Nombre_Empleado;
                        objDB.Email_Empleado            = empleado.Email_Empleado;
                        objDB.Puesto_Empleado           = empleado.Puesto_Empleado;
                        objDB.Fecha_Nacimiento_Empleado = empleado.Fecha_Nacimiento_Empleado;
                        objDB.Antiguedad_Empleado       = empleado.Antiguedad_Empleado;
                        objDB.Skype_Empleado            = empleado.Skype_Empleado;
                        objDB.Domicilio_Empleado        = empleado.Domicilio_Empleado;
                        objDB.Telefono_L_Empleado       = empleado.Telefono_L_Empleado;
                        objDB.Telefono_M_Empleado       = empleado.Telefono_M_Empleado;
                        objDB.Id_JefeInmediato_Empleado = empleado.Id_JefeInmediato_Empleado;
                        objDB.IsLogIn          = empleado.IsLogIn;
                        objDB.Usuario_Empleado = empleado.Usuario_Empleado;
                        if (empleado.Password_Empleado != string.Empty)
                        {
                            objDB.Password_Empleado = empleado.Password_Empleado;
                            objDB.Salt = empleado.Salt;
                        }
                        objDB.Estado = empleado.Estado;

                        //objDB.Id_Perfil = empleado.Id_Perfil;
                    }

                    context.SaveChanges();

                    var permisos = GuardarPermisos(empleado.EmpleadoPermiso);
                    if (permisos.Code != 0)
                    {
                        return(new MethodResponseDTO <int> {
                            Code = -100, Result = 0, Message = permisos.Message
                        });
                    }



                    return(response);
                }
                catch (DbEntityValidationException e)
                {
                    string Result = string.Empty;
                    foreach (var eve in e.EntityValidationErrors)
                    {
                        Result += string.Format("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)
                        {
                            Result += string.Format("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage);
                        }
                    }
                    Result += ("Code: -100, Mensaje: " + e.Message + ", InnerException: " + (e.InnerException != null ? e.InnerException.Message : ""));
                    return(new MethodResponseDTO <int> {
                        Code = -100, Result = 0, Message = Result
                    });
                }
                catch (Exception ex)
                {
                    return(new MethodResponseDTO <int> {
                        Code = -100, Result = 0, Message = "GuardarAsignacion: " + ex.Message
                    });
                }
            }
        }
コード例 #27
0
        /// <summary>
        /// Guardar Facturas
        /// </summary>
        /// <returns>Lista de tipo asignacion</returns>
        public MethodResponseDTO <int> GuardarFacturas(List <FacturasDTO> ltsFacturas)
        {
            using (var context = new DB_9F97CF_CatarsysSGCEntities())
            {
                try
                {
                    var response = new MethodResponseDTO <int>()
                    {
                        Code = 0, Result = 1
                    };

                    foreach (var factura in ltsFacturas)
                    {
                        if (factura.Id_Estado_Factura == 1)
                        {
                            if (factura.IdFactura == 0)
                            {
                                Facturas facturasDB = Mapper.Map <Facturas>(factura);
                                context.Facturas.Add(facturasDB);
                            }
                            else
                            {
                                var fact = context.Facturas.SingleOrDefault(x => x.IdFactura == factura.IdFactura);

                                fact.IdFactura                 = factura.IdFactura;
                                fact.IdCliente                 = factura.IdCliente;
                                fact.IdEmpresa                 = factura.IdEmpresa;
                                fact.IdAsignacion              = factura.IdAsignacion;
                                fact.IdProyecto                = factura.IdProyecto;
                                fact.C_Id_IVA                  = factura.C_Id_IVA;
                                fact.C_Id_Moneda               = factura.C_Id_Moneda;
                                fact.C_Id_Tipo_Cambio          = factura.C_Id_Tipo_Cambio;
                                fact.C_Id_Metodo_Pago          = factura.C_Id_Metodo_Pago;
                                fact.Tipo_Factura              = factura.Tipo_Factura;
                                fact.Fecha_Inicio_Factura      = factura.Fecha_Inicio_Factura;
                                fact.Fecha_fin_Factura         = factura.Fecha_fin_Factura;
                                fact.No_Factura                = factura.No_Factura;
                                fact.Descuento_Factura         = factura.Descuento_Factura;
                                fact.Monto_Factura             = factura.Monto_Factura;
                                fact.Ultimos_4_digitos_Factura = factura.Ultimos_4_digitos_Factura;
                            }
                        }
                        context.SaveChanges();
                    }

                    return(response);
                }
                catch (DbEntityValidationException e)
                {
                    string Result = string.Empty;
                    foreach (var eve in e.EntityValidationErrors)
                    {
                        Result += string.Format("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)
                        {
                            Result += string.Format("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage);
                        }
                    }
                    Result += ("Code: -100, Mensaje: " + e.Message + ", InnerException: " + (e.InnerException != null ? e.InnerException.Message : ""));
                    return(new MethodResponseDTO <int> {
                        Code = -100, Result = 0, Message = e.Message
                    });
                }
                catch (Exception ex)
                {
                    return(new MethodResponseDTO <int> {
                        Code = -100, Result = 0, Message = "GuardarAsignacion: " + ex.Message
                    });
                }
            }
        }
コード例 #28
0
        /// <summary>
        /// Guardar Asignacion
        /// </summary>
        /// <returns>Lista de tipo asignacion</returns>
        public MethodResponseDTO <int> GuardarAsignacion(AsignacionDTO asignacion)
        {
            using (var context = new DB_9F97CF_CatarsysSGCEntities())
            {
                try
                {
                    var response = new MethodResponseDTO <int>()
                    {
                        Code = 0, Result = 1
                    };


                    if (asignacion.Id_Asignacion == 0)
                    {
                        Asignacion asignacionDB = Mapper.Map <Asignacion>(asignacion);
                        context.Asignacion.Add(asignacionDB);
                    }
                    else
                    {
                        var asig = context.Asignacion.SingleOrDefault(x => x.Id_Asignacion == asignacion.Id_Asignacion);

                        asig.Id_Asignacion            = asignacion.Id_Asignacion;
                        asig.Id_Empleado_Asignacion   = asignacion.Id_Empleado_Asignacion;
                        asig.Id_Cliente_Asignacion    = asignacion.Id_Cliente_Asignacion;
                        asig.Id_Tipo_Asignacion       = asignacion.Id_Tipo_Asignacion;
                        asig.Id_Estatus_Asignacion    = asignacion.Id_Estatus_Asignacion;
                        asig.Id_Corte_Asignacion      = asignacion.Id_Corte_Asignacion;
                        asig.Id_Moneda_Asignacion     = asignacion.Id_Moneda_Asignacion;
                        asig.Id_Periodo_Asignacion    = asignacion.Id_Periodo_Asignacion;
                        asig.Id_Empresa               = asignacion.Id_Empresa;
                        asig.Id_IVA_Asignacion        = asignacion.Id_IVA_Asignacion;
                        asig.Fecha_Ini_Asignacion     = asignacion.Fecha_Ini_Asignacion;
                        asig.Fecha_Fin_Asignacion     = asignacion.Fecha_Fin_Asignacion;
                        asig.Costo_Pactado_Asignacion = asignacion.Costo_Pactado_Asignacion;
                    }
                    context.SaveChanges();

                    return(response);
                }
                catch (DbEntityValidationException e)
                {
                    string Result = string.Empty;
                    foreach (var eve in e.EntityValidationErrors)
                    {
                        Result += string.Format("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)
                        {
                            Result += string.Format("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage);
                        }
                    }
                    Result += ("Code: -100, Mensaje: " + e.Message + ", InnerException: " + (e.InnerException != null ? e.InnerException.Message : ""));
                    return(new MethodResponseDTO <int> {
                        Code = -100, Result = 0, Message = e.Message
                    });
                }
                catch (Exception ex)
                {
                    return(new MethodResponseDTO <int> {
                        Code = -100, Result = 0, Message = "GuardarAsignacion: " + ex.Message
                    });
                }
            }
        }
コード例 #29
0
        /// <summary>
        /// Guardar Empresas
        /// </summary>
        /// <returns>Lista de tipo asignacion</returns>
        public MethodResponseDTO <int> GuardarEmpresas(EmpresaDTO empresa)
        {
            using (var context = new DB_9F97CF_CatarsysSGCEntities())
            {
                try
                {
                    var response = new MethodResponseDTO <int>()
                    {
                        Code = 0, Result = 1
                    };


                    if (empresa.Id_Empresa == 0)
                    {
                        var objDB = Mapper.Map <Empresa>(empresa);
                        context.Empresa.Add(objDB);
                    }
                    else
                    {
                        var objDB = context.Empresa.SingleOrDefault(x => x.Id_Empresa == empresa.Id_Empresa);

                        objDB.Id_Empresa             = empresa.Id_Empresa;
                        objDB.Nombre_Empresa         = empresa.Nombre_Empresa;
                        objDB.Razon_Social_Empresa   = empresa.Razon_Social_Empresa;
                        objDB.RFC_Empresa            = empresa.RFC_Empresa;
                        objDB.Calle_Empresa          = empresa.Calle_Empresa;
                        objDB.No_Ext_Empresa         = empresa.No_Ext_Empresa;
                        objDB.No_Int_Empresa         = empresa.No_Int_Empresa;
                        objDB.Colonia_Empresa        = empresa.Colonia_Empresa;
                        objDB.CP_Empresa             = empresa.CP_Empresa;
                        objDB.Del_Mun_Empresa        = empresa.Del_Mun_Empresa;
                        objDB.Estado_Dom_Empresa     = empresa.Estado_Dom_Empresa;
                        objDB.Email_Empresa          = empresa.Email_Empresa;
                        objDB.Fecha_Creacion_Empresa = empresa.Fecha_Creacion_Empresa;
                        objDB.Estado_Empresa         = empresa.Estado_Empresa;
                    }
                    context.SaveChanges();

                    return(response);
                }
                catch (DbEntityValidationException e)
                {
                    string Result = string.Empty;
                    foreach (var eve in e.EntityValidationErrors)
                    {
                        Result += string.Format("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)
                        {
                            Result += string.Format("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage);
                        }
                    }
                    Result += ("Code: -100, Mensaje: " + e.Message + ", InnerException: " + (e.InnerException != null ? e.InnerException.Message : ""));
                    return(new MethodResponseDTO <int> {
                        Code = -100, Result = 0, Message = Result
                    });
                }
                catch (Exception ex)
                {
                    return(new MethodResponseDTO <int> {
                        Code = -100, Result = 0, Message = "GuardarAsignacion: " + ex.Message
                    });
                }
            }
        }
コード例 #30
0
        /// <summary>
        /// Guardar Proyecto
        /// </summary>
        /// <returns>Lista de tipo asignacion</returns>
        public MethodResponseDTO <int> GuardarProyecto(ProyectosDTO proyecto)
        {
            using (var context = new DB_9F97CF_CatarsysSGCEntities())
            {
                try
                {
                    var response = new MethodResponseDTO <int>()
                    {
                        Code = 0, Result = 1
                    };


                    if (proyecto.Id_Proyectos == 0)
                    {
                        var proyectoDB = Mapper.Map <Proyectos>(proyecto);
                        context.Proyectos.Add(proyectoDB);
                    }
                    else
                    {
                        var asig = context.Proyectos.SingleOrDefault(x => x.Id_Proyectos == proyecto.Id_Proyectos);

                        asig.Id_Proyectos              = proyecto.Id_Proyectos;
                        asig.Id_Clientes_Proyectos     = proyecto.Id_Clientes_Proyectos;
                        asig.Id_Empresa                = proyecto.Id_Empresa;
                        asig.Nombre_Proyectos          = proyecto.Nombre_Proyectos;
                        asig.Fecha_Ini_Proyectos       = proyecto.Fecha_Ini_Proyectos;
                        asig.Fecha_Fin_Proyectos       = proyecto.Fecha_Fin_Proyectos;
                        asig.Costo_Proyectos           = proyecto.Costo_Proyectos;
                        asig.Id_Moneda_Proyectos       = proyecto.Id_Moneda_Proyectos;
                        asig.Numero_Facturas_Proyectos = proyecto.Numero_Facturas_Proyectos;
                        asig.Id_Tipo_Cambio_Proyectos  = proyecto.Id_Tipo_Cambio_Proyectos;
                        asig.Id_IVA_Proyectos          = proyecto.Id_IVA_Proyectos;
                        asig.Estado = proyecto.Estado;
                    }
                    context.SaveChanges();


                    var _FacturasData = new FacturasData();

                    var BrFacturas = _FacturasData.BorrarFacturas(proyecto.Id_Proyectos, 1);

                    if (BrFacturas.Code != 0)
                    {
                        return(new MethodResponseDTO <int> {
                            Code = -100, Result = 0, Message = "Borrar Facturas: " + BrFacturas.Message
                        });
                    }

                    var Facturas = _FacturasData.GuardarFacturas(proyecto.facturas);

                    if (Facturas.Code != 0)
                    {
                        return(new MethodResponseDTO <int> {
                            Code = -100, Result = 0, Message = "Guardar Facturas: " + Facturas.Message
                        });
                    }


                    return(response);
                }
                catch (DbEntityValidationException e)
                {
                    string Result = string.Empty;
                    foreach (var eve in e.EntityValidationErrors)
                    {
                        Result += string.Format("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)
                        {
                            Result += string.Format("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage);
                        }
                    }
                    Result += ("Code: -100, Mensaje: " + e.Message + ", InnerException: " + (e.InnerException != null ? e.InnerException.Message : ""));
                    return(new MethodResponseDTO <int> {
                        Code = -100, Result = 0, Message = e.Message
                    });
                }
                catch (Exception ex)
                {
                    return(new MethodResponseDTO <int> {
                        Code = -100, Result = 0, Message = "Guardar Proyecto: " + ex.Message
                    });
                }
            }
        }