Пример #1
0
 public ActionResult Create(int id)
 {
     var ar = new AgenziaRepository();
     var agency = ar.GetById(id);
     var model = new Viaggio
     {
         Agenzia = agency,
         Nome = string.Format("Nuovo Viaggio {0}", vr.GetListaViaggiByAgenzia(agency).Count + 1),
         Descrizione = string.Format("Nuovo Viaggio di {0}", agency.Nome),
         Approvato = false,
     };
     vr.Save(model);
     return RedirectToAction("Edit", new { id = model.Id });
 }
Пример #2
0
 public ActionResult Register(RegisterViewModel viewModel)
 {
     if (ModelState.IsValid)
     {
         CryptoHelper cryptoHelper = new CryptoHelper();
         var agency = viewModel.Agenzia;
         agency.Password = cryptoHelper.CryptPassword(agency.Password);
         var ar = new AgenziaRepository();
         ar.Save(agency);
         Session.Login(agency);
         if (agency.IsTourOperator)
             return RedirectToAction("TourOperatorDashboard", "Dashboard", new { id = agency.Id });
         return RedirectToAction("AgenziaDashboard", "Dashboard", new { id = agency.Id });
     }
     else return View(viewModel);
 }
Пример #3
0
 public ActionResult Login(string password, string email)
 {
     CryptoHelper cryptoHelper = new CryptoHelper();
     var ar = new AgenziaRepository();
     var agency = ar.GetByEmail(email);
     if (agency == null)
         return View("Register");
     var cryptedPassword = cryptoHelper.CryptPassword(password);
     if (cryptedPassword.Equals(agency.Password))
     {
         Session.Login(agency);
         if (agency.IsTourOperator)
             return RedirectToAction("TourOperatorDashboard", "Dashboard", new { id = agency.Id });
         return RedirectToAction("AgenziaDashboard", "Dashboard", new { id = agency.Id });
     }
     var viewModel = new RegisterViewModel();
     return View("Register", viewModel);
 }
Пример #4
0
 public ActionResult SendMailingList(DateTime dataApprovazione)
 {
     var vr = new ViaggioRepository();
     var viaggi = vr.GetApproved().Where(c => c.DataApprovazione >= dataApprovazione);
     if (viaggi.Count() > 0)
     {
         var ar = new AgenziaRepository();
         var agenzie = ar.GetAllAgenzie(100, 0);
         if (agenzie.Count > 0)
         {
             var mh = new MailerHelper();
             var mlh = new MailingListHelper();
             var mailText = mlh.GetMailingList(viaggi.ToList());
             foreach (var agenzia in agenzie)
                 mh.SendMail(agenzia.Email, mailText);
         }
     }
     return RedirectToAction("AdminDashBoard", "Dashboard");
 }
Пример #5
0
        public static AuthenticationResult AuthenticateUtente(String name, String password)
        {
            AuthenticationResult result = null;

            AgenziaRepository ur = new AgenziaRepository();
            var registeredAgenzia = ur.GetByName(name);

            if (registeredAgenzia == null)
            {
                result = new AuthenticationResult { IsAuthenticated = false, AuthErrorMessage = "Username/Password errata!" };
            }
            else
            {
                CryptoHelper crypter = new CryptoHelper();
                if (crypter.CryptPassword(password).Equals(registeredAgenzia.Password))
                    result = new AuthenticationResult { IsAuthenticated = true, AuthenticatedAgenzia = registeredAgenzia };
                else
                    result = new AuthenticationResult { IsAuthenticated = false, AuthErrorMessage = "Username/Password errata!" };
            }
            return result;
        }
Пример #6
0
 public ActionResult ResetPassword(string email)
 {
     var ar = new AgenziaRepository();
     var agency = ar.GetByEmail(email);
     if (agency != null)
     {
         CryptoHelper cryptoHelper = new CryptoHelper();
         var random = new Random();
         var password = random.Next().ToString();
         agency.Password = cryptoHelper.CryptPassword(password);
         ar.Save(agency);
         var mailerHelper = new MailerHelper();
         var text = string.Format("Gentile {0} la tua nuova password di Parti Comodo è: {1}", agency.Nome, password);
         mailerHelper.SendMail(email, text);
     }
     var viewModel = new RegisterViewModel();
     return View("Register", viewModel);
 }
Пример #7
0
 public ActionResult ListMineNotApproved(int id)
 {
     var ar = new AgenziaRepository();
     var agency = ar.GetById(id);
     var model = vr.GetUnapproved().Where(c => c.Agenzia.Id == agency.Id);
     return View(model.ToList());
 }
Пример #8
0
 public ActionResult ListMine(int id)
 {
     var ar = new AgenziaRepository();
     var agency = ar.GetById(id);
     var model = vr.GetListaViaggiByAgenzia(agency);
     return View(model);
 }
Пример #9
0
 public ActionResult TourOperatorDashBoard(int id)
 {
     var ar = new AgenziaRepository();
     var model = ar.GetById(id);
     return View(model);
 }
Пример #10
0
 public IList<Viaggio> GetProposteAgenzia(Agenzia agenzia)
 {
     var ar = new AgenziaRepository();
     using (var om = new OperationManager())
     {
         try
         {
             var session = om.BeginOperation();
             logger.Info("Recupero dei viaggi proposti dall'agenzia {0}", agenzia);
             var viaggi = session.Query<Viaggio>()
                             .Where(v => v.Agenzia.Id == agenzia.Id)
                             .ToList();
             logger.Debug("Viaggi proposti: {0}", viaggi.Count);
             om.CommitOperation();
             return viaggi;
         }
         catch (Exception ex)
         {
             om.RollbackOperation();
             string msg = String.Format("Impossibile recuperare i viaggi proposti dall'agenzia {0}", agenzia);
             logger.ErrorException(msg, ex);
             throw new Exception(msg, ex);
         }
     }
 }