Inheritance: INotifyPropertyChanging, INotifyPropertyChanged
        // ******************
        // controller methods
        // ******************
        // creates a movement.
        public void createMovement(Movimiento movement)
        {
            // fixes the movement settings
            movement.habilitado = true;
            movement.url.Replace(' ', '_');
            if (movement.maxMarcasInadecuadasRecursoX < 1)
            {
                movement.maxMarcasInadecuadasRecursoX = 5;
            }
            if (movement.maxRecursosInadecuadosUsuarioZ < 1)
            {
                movement.maxRecursosInadecuadosUsuarioZ = 5;
            }
            if (movement.maxRecursosPopularesN < 1)
            {
                movement.maxRecursosPopularesN = 5;
            }
            if (movement.maxUltimosRecursosM < 1)
            {
                movement.maxUltimosRecursosM = 5;
            }

            // creates the movement.
            IndignadoDBDataContext indignadoContext = new IndignadoDBDataContext();
            indignadoContext.Movimientos.InsertOnSubmit(movement);
            indignadoContext.SubmitChanges();

            // get the movement's id.
            IEnumerable<Movimiento> movementsEnum = indignadoContext.ExecuteQuery<Movimiento> ("SELECT id FROM Movimiento WHERE nombre = {0}", movement.nombre);

            int idMov = -1;
            foreach (Movimiento mov in movementsEnum)
            {
                if (mov.nombre == movement.nombre)
                {
                    idMov = mov.id;
                }
            }

            // creates the movement admin.
            DTRegisterModel user = new DTRegisterModel();
            user.nombre = "movadmin";
            user.apodo = "movadmin";
            user.contraseƱa = "1234";
            user.idMovimiento = idMov;
            user.latitud = (float)movement.latitud;
            user.longitud = (float)movement.longitud;
            user.mail = movement.nombre + "@tsi1.com.uy";

            Usuario userDb = DTToClass.DTToUsuario(user);
            userDb.banned = false;
            userDb.privilegio = (short) Roles.MovAdminMask;
            userDb.fechaRegistro = new DateTime(DateTime.UtcNow.Year, DateTime.UtcNow.Month, DateTime.UtcNow.Day, DateTime.UtcNow.Hour, DateTime.UtcNow.Minute, 0);
            indignadoContext.Usuarios.InsertOnSubmit(userDb);

            // submit changes to the database
            indignadoContext.SubmitChanges();
        }
Example #2
0
 public static Movimiento DTToMovement(DTMovement dtMovement)
 {
     Movimiento movement = new Movimiento();
     movement.id = dtMovement.id;
     movement.nombre = dtMovement.name;
     movement.descripcion = dtMovement.description;
     movement.latitud = dtMovement.locationLati;
     movement.longitud = dtMovement.locationLong;
     movement.idLayout = dtMovement.idLayout;
     movement.logo = dtMovement.imagePath;
     movement.url = dtMovement.subURL;
     movement.maxMarcasInadecuadasRecursoX = dtMovement.maxMarcasInadecuadasRecursoX;
     movement.maxRecursosInadecuadosUsuarioZ = dtMovement.maxRecursosInadecuadosUsuarioZ;
     movement.maxRecursosPopularesN = dtMovement.maxRecursosPopularesN;
     movement.maxUltimosRecursosM = dtMovement.maxUltimosRecursosM;
     return movement;
 }
Example #3
0
        public static DTMovement MovementToDT(Movimiento movement)
        {
            DTMovement dtMovement = new DTMovement();
            dtMovement.id = movement.id;
            dtMovement.name = movement.nombre;
            dtMovement.description = movement.descripcion;
            dtMovement.locationLati = (float)movement.latitud;
            dtMovement.locationLong = (float)movement.longitud;
            dtMovement.idLayout = movement.idLayout;
            dtMovement.imagePath = movement.logo;
            dtMovement.subURL = movement.url;
            dtMovement.maxMarcasInadecuadasRecursoX = movement.maxMarcasInadecuadasRecursoX;
            dtMovement.maxRecursosInadecuadosUsuarioZ = movement.maxRecursosInadecuadosUsuarioZ;
            dtMovement.maxRecursosPopularesN = movement.maxRecursosPopularesN;
            dtMovement.maxUltimosRecursosM = movement.maxUltimosRecursosM;
            dtMovement.habilitado = movement.habilitado;

            return dtMovement;
        }
 partial void DeleteMovimiento(Movimiento instance);
 partial void UpdateMovimiento(Movimiento instance);
 partial void InsertMovimiento(Movimiento instance);
		private void detach_Movimientos(Movimiento entity)
		{
			this.SendPropertyChanging();
			entity.Layout = null;
		}
		private void attach_Movimientos(Movimiento entity)
		{
			this.SendPropertyChanging();
			entity.Layout = this;
		}
 // changes the configuration of the movement.
 public void setMovement(Movimiento movement)
 {
     IndignadoDBDataContext indignadoContext = new IndignadoDBDataContext();
     Movimiento mov = indignadoContext.Movimientos.SingleOrDefault(m => m.id == IdMovement);
     mov.nombre = movement.nombre;
     mov.descripcion = movement.descripcion;
     mov.latitud = movement.latitud;
     mov.longitud = movement.longitud;
     mov.idLayout = movement.idLayout;
     if ((movement.logo != null) && (movement.logo != ""))
     {
         mov.logo = movement.logo;
     }
     mov.maxMarcasInadecuadasRecursoX = movement.maxMarcasInadecuadasRecursoX;
     mov.maxRecursosInadecuadosUsuarioZ = movement.maxRecursosInadecuadosUsuarioZ;
     mov.maxRecursosPopularesN = movement.maxRecursosPopularesN;
     mov.maxUltimosRecursosM = movement.maxUltimosRecursosM;
     indignadoContext.SubmitChanges();
     //indignadoContext.ExecuteCommand("UPDATE Movimiento SET nombre = {0}, descripcion = {1}, latitud = {2}, longitud = {3}, idLayout = {4}, logo={6} WHERE id = {5}", movement.nombre, movement.descripcion, movement.latitud, movement.longitud, movement.idLayout, IdMovement);
 }