// GET: Admin/Delete/5
        public ActionResult Delete(int id)
        {
            try
            {
                /*SessionInitialize();
                 * AdminCAD adminCAD = new AdminCAD(session);
                 * AdminCEN adminCEN = new AdminCEN(adminCAD);
                 * AdminEN adminEN = adminCEN.ReadOID(id);
                 * AdminViewModel art = new AssemblerAdmin().ConvertENToModelUI(adminEN);
                 * SessionClose();
                 *
                 * new AdminCEN().Destroy(id);
                 *
                 *
                 * return RedirectToAction("Index");*/

                SessionInitialize();
                AdminCAD       adminCAD = new AdminCAD(session);
                AdminCEN       adminCEN = new AdminCEN(adminCAD);
                AdminEN        adminEN  = adminCEN.ReadOID(id);
                AdminViewModel adminVM  = new AssemblerAdmin().ConvertENToModelUI(adminEN);

                SessionClose();

                return(View(adminVM));
            }
            catch
            {
                return(View());
            }

            //return View();
        }
Exemple #2
0
        public string New_(string p_nombre, string p_apellidos, String p_contrasenya, string p_email, string p_direccion, string p_tarjeta, string p_imagen)
        {
            AdminEN adminEN = null;
            string  oid;

            //Initialized AdminEN
            adminEN        = new AdminEN();
            adminEN.Nombre = p_nombre;

            adminEN.Apellidos = p_apellidos;

            adminEN.Contrasenya = Utils.Util.GetEncondeMD5(p_contrasenya);

            adminEN.Email = p_email;

            adminEN.Direccion = p_direccion;

            adminEN.Tarjeta = p_tarjeta;

            adminEN.Imagen = p_imagen;

            //Call to AdminCAD

            oid = _IAdminCAD.New_(adminEN);
            return(oid);
        }
Exemple #3
0
        public void BorrarAdmin(int usuarioID
                                )
        {
            try
            {
                SessionInitializeTransaction();
                AdminEN adminEN = (AdminEN)session.Load(typeof(AdminEN), usuarioID);
                session.Delete(adminEN);
                SessionCommit();
            }

            catch (Exception ex) {
                SessionRollBack();
                if (ex is BookReViewGenNHibernate.Exceptions.ModelException)
                {
                    throw ex;
                }
                throw new BookReViewGenNHibernate.Exceptions.DataLayerException("Error in AdminCAD.", ex);
            }


            finally
            {
                SessionClose();
            }
        }
        public int New_(string p_nombre, string p_apellidos, int p_edad, Nullable <DateTime> p_fecha_nac, string p_dni, String p_contraseña, string p_n_usuario, DSM1GenNHibernate.EN.DSM1.CarritoEN p_carrito)
        {
            AdminEN adminEN = null;
            int     oid;

            //Initialized AdminEN
            adminEN        = new AdminEN();
            adminEN.Nombre = p_nombre;

            adminEN.Apellidos = p_apellidos;

            adminEN.Edad = p_edad;

            adminEN.Fecha_nac = p_fecha_nac;

            adminEN.Dni = p_dni;

            adminEN.Contraseña = Utils.Util.GetEncondeMD5(p_contraseña);

            adminEN.N_usuario = p_n_usuario;

            adminEN.Carrito = p_carrito;

            //Call to AdminCAD

            oid = _IAdminCAD.New_(adminEN);
            return(oid);
        }
Exemple #5
0
        public int New_(int p_usuario, string p_nombre, int p_ID)
        {
            AdminEN adminEN = null;
            int     oid;

            //Initialized AdminEN
            adminEN = new AdminEN();

            if (p_usuario != -1)
            {
                // El argumento p_usuario -> Property usuario es oid = false
                // Lista de oids ID
                adminEN.Usuario    = new WhateverGenNHibernate.EN.Whatever.UsuarioEN();
                adminEN.Usuario.ID = p_usuario;
            }

            adminEN.Nombre = p_nombre;

            adminEN.ID = p_ID;

            //Call to AdminCAD

            oid = _IAdminCAD.New_(adminEN);
            return(oid);
        }
Exemple #6
0
        public string New_(string p_email, string p_nombre, string p_apellidos, string p_nick, String p_contrasenya, Nullable <DateTime> p_fecha_nac, DSMGitGenNHibernate.Enumerated.DSMGit.RolEnum p_rol, string p_imagen, string p_descripcion)
        {
            AdminEN adminEN = null;
            string  oid;

            //Initialized AdminEN
            adminEN       = new AdminEN();
            adminEN.Email = p_email;

            adminEN.Nombre = p_nombre;

            adminEN.Apellidos = p_apellidos;

            adminEN.Nick = p_nick;

            adminEN.Contrasenya = Utils.Util.GetEncondeMD5(p_contrasenya);

            adminEN.Fecha_nac = p_fecha_nac;

            adminEN.Rol = p_rol;

            adminEN.Imagen = p_imagen;

            adminEN.Descripcion = p_descripcion;

            //Call to AdminCAD

            oid = _IAdminCAD.New_(adminEN);
            return(oid);
        }
        // GET: Admin/Delete/5
        public ActionResult Delete(int id)
        {
            try
            {
                // TODO: Add delete logic here
                //int idCategoria = -1;
                SessionInitialize();
                AdminCAD       adminCAD = new AdminCAD(session);
                AdminCEN       adminCEN = new AdminCEN(adminCAD);
                AdminEN        adminEN  = adminCEN.ReadOID(id);
                AdminViewModel art      = new AssemblerAdmin().ConvertENToModelUI(adminEN);
                //idCategoria = art.IdCategoria;
                SessionClose();

                new AdminCEN().Destroy(id);


                //return RedirectToAction("PorCategoria", new { id = idCategoria });
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }

            //return View();
        }
Exemple #8
0
        public int NewAdmin(AdminEN admin)
        {
            try
            {
                SessionInitializeTransaction();

                session.Save(admin);
                SessionCommit();
            }

            catch (Exception ex) {
                SessionRollBack();
                if (ex is PickadosGenNHibernate.Exceptions.ModelException)
                {
                    throw ex;
                }
                throw new PickadosGenNHibernate.Exceptions.DataLayerException("Error in AdminCAD.", ex);
            }


            finally
            {
                SessionClose();
            }

            return(admin.Id);
        }
Exemple #9
0
        public Usuario ConvertENToModelUI(AdminEN en)
        {
            Usuario art = new Usuario();

            //art.id = en.;



            art.Nombre    = en.Nombre;
            art.Apellidos = en.Apellidos;
            art.Password  = en.Contrasenya;
            art.Email     = en.Email;
            art.Direccion = en.Direccion;
            art.Tarjeta   = en.Tarjeta;
            art.Imagen    = en.Imagen;
            if (en.Lista != null)
            {
                art.siguiendo = en.Lista.ElementAt(0).Id;
                art.favorito  = en.Lista.ElementAt(1).Id;
                art.visto     = en.Lista.ElementAt(2).Id;
            }



            if (en.Carrito != null)
            {
                art.carrito = en.Carrito.Id;
            }

            return(art);
        }
Exemple #10
0
//Sin e: GetID
//Con e: AdminEN
        public AdminEN GetID(int ID
                             )
        {
            AdminEN adminEN = null;

            try
            {
                SessionInitializeTransaction();
                adminEN = (AdminEN)session.Get(typeof(AdminEN), ID);
                SessionCommit();
            }

            catch (Exception ex) {
                SessionRollBack();
                if (ex is WhateverGenNHibernate.Exceptions.ModelException)
                {
                    throw ex;
                }
                throw new WhateverGenNHibernate.Exceptions.DataLayerException("Error in AdminCAD.", ex);
            }


            finally
            {
                SessionClose();
            }

            return(adminEN);
        }
Exemple #11
0
        public void Modify(AdminEN admin)
        {
            try
            {
                SessionInitializeTransaction();
                AdminEN adminEN = (AdminEN)session.Load(typeof(AdminEN), admin.ID);

                adminEN.Nombre = admin.Nombre;

                session.Update(adminEN);
                SessionCommit();
            }

            catch (Exception ex) {
                SessionRollBack();
                if (ex is WhateverGenNHibernate.Exceptions.ModelException)
                {
                    throw ex;
                }
                throw new WhateverGenNHibernate.Exceptions.DataLayerException("Error in AdminCAD.", ex);
            }


            finally
            {
                SessionClose();
            }
        }
Exemple #12
0
        public int New_(AdminEN admin)
        {
            try
            {
                SessionInitializeTransaction();
                if (admin.Usuario != null)
                {
                    // Argumento OID y no colección.
                    admin.Usuario = (WhateverGenNHibernate.EN.Whatever.UsuarioEN)session.Load(typeof(WhateverGenNHibernate.EN.Whatever.UsuarioEN), admin.Usuario.ID);

                    admin.Usuario.Admin
                        = admin;
                }

                session.Save(admin);
                SessionCommit();
            }

            catch (Exception ex) {
                SessionRollBack();
                if (ex is WhateverGenNHibernate.Exceptions.ModelException)
                {
                    throw ex;
                }
                throw new WhateverGenNHibernate.Exceptions.DataLayerException("Error in AdminCAD.", ex);
            }


            finally
            {
                SessionClose();
            }

            return(admin.ID);
        }
Exemple #13
0
        public void Modify(AdminEN admin)
        {
            try
            {
                SessionInitializeTransaction();
                AdminEN adminEN = (AdminEN)session.Load(typeof(AdminEN), admin.Id);

                adminEN.Email = admin.Email;


                adminEN.Pass = admin.Pass;


                adminEN.Fecha_inscripcion = admin.Fecha_inscripcion;

                session.Update(adminEN);
                SessionCommit();
            }

            catch (Exception ex) {
                SessionRollBack();
                if (ex is LePapeoGenNHibernate.Exceptions.ModelException)
                {
                    throw ex;
                }
                throw new LePapeoGenNHibernate.Exceptions.DataLayerException("Error in AdminCAD.", ex);
            }


            finally
            {
                SessionClose();
            }
        }
Exemple #14
0
        public AdminEN ReadOIDDefault(string email
                                      )
        {
            AdminEN adminEN = null;

            try
            {
                SessionInitializeTransaction();
                adminEN = (AdminEN)session.Get(typeof(AdminEN), email);
                SessionCommit();
            }

            catch (Exception ex) {
                SessionRollBack();
                if (ex is DSMGitGenNHibernate.Exceptions.ModelException)
                {
                    throw ex;
                }
                throw new DSMGitGenNHibernate.Exceptions.DataLayerException("Error in AdminCAD.", ex);
            }


            finally
            {
                SessionClose();
            }

            return(adminEN);
        }
Exemple #15
0
        public int New_(string p_nombre, string p_alias, Nullable <DateTime> p_fechaRegistro, String p_password, string p_email, bool p_suscrito, int p_idioma, string p_imagen)
        {
            AdminEN adminEN = null;
            int     oid;

            //Initialized AdminEN
            adminEN        = new AdminEN();
            adminEN.Nombre = p_nombre;

            adminEN.Alias = p_alias;

            adminEN.FechaRegistro = p_fechaRegistro;

            adminEN.Password = Utils.Util.GetEncondeMD5(p_password);

            adminEN.Email = p_email;

            adminEN.Suscrito = p_suscrito;


            if (p_idioma != -1)
            {
                // El argumento p_idioma -> Property idioma es oid = false
                // Lista de oids id
                adminEN.Idioma    = new OscarsitosGenNHibernate.EN.Oscarsitos.IdiomaEN();
                adminEN.Idioma.Id = p_idioma;
            }

            adminEN.Imagen = p_imagen;

            //Call to AdminCAD

            oid = _IAdminCAD.New_(adminEN);
            return(oid);
        }
Exemple #16
0
        public string New_(AdminEN admin)
        {
            try
            {
                SessionInitializeTransaction();

                session.Save(admin);
                SessionCommit();
            }

            catch (Exception ex) {
                SessionRollBack();
                if (ex is DSMGitGenNHibernate.Exceptions.ModelException)
                {
                    throw ex;
                }
                throw new DSMGitGenNHibernate.Exceptions.DataLayerException("Error in AdminCAD.", ex);
            }


            finally
            {
                SessionClose();
            }

            return(admin.Email);
        }
Exemple #17
0
        public void ModificarAdmin(AdminEN admin)
        {
            try
            {
                SesssionInitializeTransaction();
                AdminEN adminEN = (AdminEN)session.Load(typeof(AdminEN), admin.IdAdmin);

                adminEN.Email = admin.Email;


                adminEN.Passwd = admin.Passwd;


                adminEN.Nombre = admin.Nombre;

                session.Update(adminEN);
                SessionCommit();
            }

            catch (Exception ex) {
                SessionRollBack();
                if (ex is ModelException)
                {
                    throw ex;
                }
                throw new DataLayerException("Error in AdminCAD.", ex);
            }


            finally
            {
                SessionClose();
            }
        }
Exemple #18
0
        public void Destroy(string Usr)
        {
            try
            {
                SessionInitializeTransaction();
                AdminEN adminEN = (AdminEN)session.Load(typeof(AdminEN), Usr);
                session.Delete(adminEN);
                SessionCommit();
            }

            catch (Exception ex) {
                SessionRollBack();
                if (ex is RetappGenNHibernate.Exceptions.ModelException)
                {
                    throw ex;
                }
                throw new RetappGenNHibernate.Exceptions.DataLayerException("Error in AdminCAD.", ex);
            }


            finally
            {
                SessionClose();
            }
        }
        public int New_(AdminEN admin)
        {
            try
            {
                SessionInitializeTransaction();
                if (admin.Carrito != null)
                {
                    // p_carrito
                    admin.Carrito.Registrado = admin;
                    session.Save(admin.Carrito);
                }

                session.Save(admin);
                SessionCommit();
            }

            catch (Exception ex) {
                SessionRollBack();
                if (ex is DSM1GenNHibernate.Exceptions.ModelException)
                {
                    throw ex;
                }
                throw new DSM1GenNHibernate.Exceptions.DataLayerException("Error in AdminCAD.", ex);
            }


            finally
            {
                SessionClose();
            }

            return(admin.Id);
        }
Exemple #20
0
        public AdminEN ReadOIDDefault(int idAdmin)
        {
            AdminEN adminEN = null;

            try
            {
                SesssionInitializeTransaction();
                adminEN = (AdminEN)session.Load(typeof(AdminEN),
                                                idAdmin

                                                );
                SessionCommit();
            }

            catch (Exception ex) {
                SessionRollBack();
                if (ex is ModelException)
                {
                    throw ex;
                }
                throw new DataLayerException("Error in AdminCAD.", ex);
            }


            finally
            {
                SessionClose();
            }

            return(adminEN);
        }
Exemple #21
0
        public int CrearAdmin(AdminEN admin)
        {
            try
            {
                SesssionInitializeTransaction();

                session.Save(admin);
                SessionCommit();
            }

            catch (Exception ex) {
                SessionRollBack();
                if (ex is ModelException)
                {
                    throw ex;
                }
                throw new DataLayerException("Error in AdminCAD.", ex);
            }


            finally
            {
                SessionClose();
            }

            return(admin.IdAdmin);
        }
Exemple #22
0
        public void EliminarAdmin(int idAdmin)
        {
            try
            {
                SesssionInitializeTransaction();
                AdminEN adminEN = (AdminEN)session.Load(typeof(AdminEN),
                                                        idAdmin

                                                        );
                session.Delete(adminEN);
                SessionCommit();
            }

            catch (Exception ex) {
                SessionRollBack();
                if (ex is ModelException)
                {
                    throw ex;
                }
                throw new DataLayerException("Error in AdminCAD.", ex);
            }


            finally
            {
                SessionClose();
            }
        }
Exemple #23
0
        public int New_(AdminEN admin)
        {
            try
            {
                SessionInitializeTransaction();
                if (admin.Idioma != null)
                {
                    // Argumento OID y no colección.
                    admin.Idioma = (OscarsitosGenNHibernate.EN.Oscarsitos.IdiomaEN)session.Load(typeof(OscarsitosGenNHibernate.EN.Oscarsitos.IdiomaEN), admin.Idioma.Id);

                    admin.Idioma.Conectado
                    .Add(admin);
                }

                session.Save(admin);
                SessionCommit();
            }

            catch (Exception ex) {
                SessionRollBack();
                if (ex is OscarsitosGenNHibernate.Exceptions.ModelException)
                {
                    throw ex;
                }
                throw new OscarsitosGenNHibernate.Exceptions.DataLayerException("Error in AdminCAD.", ex);
            }


            finally
            {
                SessionClose();
            }

            return(admin.Id);
        }
Exemple #24
0
// Modify default (Update all attributes of the class)

        public void ModifyDefault(AdminEN admin)
        {
            try
            {
                SessionInitializeTransaction();
                AdminEN adminEN = (AdminEN)session.Load(typeof(AdminEN), admin.Email);
                session.Update(adminEN);
                SessionCommit();
            }

            catch (Exception ex) {
                SessionRollBack();
                if (ex is DSMGitGenNHibernate.Exceptions.ModelException)
                {
                    throw ex;
                }
                throw new DSMGitGenNHibernate.Exceptions.DataLayerException("Error in AdminCAD.", ex);
            }


            finally
            {
                SessionClose();
            }
        }
Exemple #25
0
        public AdminEN ReadOID(string Email
                               )
        {
            AdminEN adminEN = null;

            adminEN = _IAdminCAD.ReadOID(Email);
            return(adminEN);
        }
Exemple #26
0
        public AdminEN ReadOID(int usuarioID
                               )
        {
            AdminEN adminEN = null;

            adminEN = _IAdminCAD.ReadOID(usuarioID);
            return(adminEN);
        }
Exemple #27
0
        public AdminEN ReadOID(int id
                               )
        {
            AdminEN adminEN = null;

            adminEN = _IAdminCAD.ReadOID(id);
            return(adminEN);
        }
Exemple #28
0
        public AdminEN GetID(int ID
                             )
        {
            AdminEN adminEN = null;

            adminEN = _IAdminCAD.GetID(ID);
            return(adminEN);
        }
Exemple #29
0
        public AdminEN DamePorID(int idAdmin)
        {
            AdminEN adminEN = null;

            adminEN = _IAdminCAD.DamePorID(
                idAdmin

                );
            return(adminEN);
        }
Exemple #30
0
        public void Modify(int p_Admin_OID)
        {
            AdminEN adminEN = null;

            //Initialized AdminEN
            adminEN    = new AdminEN();
            adminEN.Id = p_Admin_OID;
            //Call to AdminCAD

            _IAdminCAD.Modify(adminEN);
        }