public ResponseViewModel ChangePassword(ChangePasswordAccountViewModel model)
        {
            ResponseViewModel reponse = new ResponseViewModel();

            try
            {
                var userNameExist = eventPlusContext.Login.Where(w => w.UserName == model.Username).FirstOrDefault();
                if (userNameExist == null)
                {
                    reponse.Type     = "error";
                    reponse.Response = "El usuario ingresado no existe.";
                }
                else
                {
                    var oldPassword = eventPlusContext.Login.Where(w => w.Password == model.OldPassword).FirstOrDefault();
                    if (oldPassword == null)
                    {
                        reponse.Type     = "error";
                        reponse.Response = "La clave actual no coincide";
                    }
                    else
                    {
                        if (!model.NewPassword.Equals(model.RepeatNewPassword))
                        {
                            reponse.Type     = "error";
                            reponse.Response = "La clave nueva y la confirmación de la clave nueva ingresadas, no coinciden.";
                        }
                        else
                        {
                            var changePassword = eventPlusContext.Login.Where(w => w.Password == model.OldPassword && w.UserName == model.Username).FirstOrDefault();
                            changePassword.Password = model.NewPassword;

                            eventPlusContext.Login.Add(changePassword);
                            eventPlusContext.Entry(changePassword).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                            eventPlusContext.SaveChanges();

                            reponse.Type     = "success";
                            reponse.Response = "Cambio de clave exitoso.";
                        }
                    }
                }

                return(reponse);
            }
            catch (Exception ex)
            {
                reponse.Type     = "error";
                reponse.Response = "Error en el procedimiento. ---> " + ex.Message;
                return(reponse);
            }
        }
        public ResponseViewModel UptadeNotificacion(NotificacionesViewModel model)
        {
            ResponseViewModel reponse = new ResponseViewModel();

            try
            {
                var notiExi = _eventPlusContext.Notificaciones.Where(w => w.Id == model.Id).FirstOrDefault();

                if (notiExi == null)
                {
                    reponse.Type     = "error";
                    reponse.Response = "La notificación no existe ";
                    return(reponse);
                }
                notiExi.Entregado = "1";

                _eventPlusContext.Notificaciones.Add(notiExi);
                _eventPlusContext.Entry(notiExi).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                _eventPlusContext.SaveChanges();

                reponse.Type     = "success";
                reponse.Response = "El regitsro se ha actulizado.";

                return(reponse);
            }
            catch (Exception ex)
            {
                reponse.Type     = "error";
                reponse.Response = "Error en el procedimiento. ---> " + ex.Message;
                return(reponse);
            }
        }
Exemple #3
0
        public ResponseViewModel DeleteLike(int idEvent, int idLogin)
        {
            ResponseViewModel reponse = new ResponseViewModel();

            try
            {
                var categoriaLike = _eventPlusContext.ParametrizacionObjetos.Where(s => s.Nombre == "CAT_HISTORICO" && s.Valor == "Like").FirstOrDefault();
                var eliminar      = _eventPlusContext.Categoria.Where(w => w.IdCategoria == categoriaLike.Id && w.IdEvento == idEvent && w.IdLogin == idLogin).FirstOrDefault();

                _eventPlusContext.Categoria.Remove(eliminar);
                _eventPlusContext.Entry(eliminar).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                _eventPlusContext.SaveChanges();

                return(reponse);
            }
            catch (Exception ex)
            {
                reponse.Type     = "error";
                reponse.Response = "Error en el procedimiento. ---> " + ex.Message;
                return(reponse);
            }
        }