示例#1
0
        public string ActualizarTipoServicio(TIPO_SERVICIO tipoServicio)
        {
            try
            {
                EntitiesServiexpress con = new EntitiesServiexpress();
                var tipo = (from a in con.TIPO_SERVICIO
                            where a.NOMBRE == tipoServicio.NOMBRE
                            select a).FirstOrDefault();

                if (tipo == null)
                {
                    var tipo2 = (from a in con.TIPO_SERVICIO
                                 where a.ID == tipoServicio.ID
                                 select a).FirstOrDefault();

                    tipo2.NOMBRE = tipoServicio.NOMBRE;
                    tipo2.FECHA_ULTIMO_UPDATE = tipoServicio.FECHA_ULTIMO_UPDATE;
                    con.SaveChanges();
                    return("actualizado");
                }
                else
                {
                    return("El tipo servicio ya existe con ese nombre en los registros, pruebe con otro");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#2
0
        public string CrearTipoServicio(TIPO_SERVICIO tipoServicio)
        {
            try
            {
                EntitiesServiexpress con = new EntitiesServiexpress();
                var _exTipoServicio      = (from a in con.TIPO_SERVICIO
                                            where a.NOMBRE == tipoServicio.NOMBRE
                                            select a).FirstOrDefault();

                if (_exTipoServicio == null)
                {
                    con.TIPO_SERVICIO.Add(tipoServicio);
                    con.SaveChanges();
                    return("creado");
                }
                else
                {
                    return("El tipo de servicio ya existe en los registros");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }