Esempio n. 1
0
        public static void CheckAndSend()
        {
            lock (typeof(MailChecker)) // блок-ка
            {
                List<Lot> lotList = new LotRepository().GetInactiveLot();
                if (lotList != null)
                {
                    foreach (Lot lot in lotList)
                    {
                        if (lot != null)
                        {

                            if (lot.Customer_id != 0)
                            {
                                User userCustomer = new UserRepository().GetDBUser(lot.Customer_id);
                                MailSender.SendMail(4, userCustomer, lot);
                                User userOwner = new UserRepository().GetDBUser(lot.Owner_id);
                                MailSender.SendMail(6, userOwner, lot);
                            }
                            else
                            {
                                User user = new UserRepository().GetDBUser(lot.Owner_id);
                                MailSender.SendMail(7, user, lot);
                            }
                            //  lot.DateEnd
                        }
                    }
                }
            }
        }
Esempio n. 2
0
 // **************************************
 // URL: /Account/Activate/username/key
 // **************************************
 public ActionResult Activate(string username, string key)
 {
     UserRepository _user = new UserRepository();
     if (_user.ActivateUser(username, key) == false)
         ViewBag.Status = "Your account wasn't activated";
     else ViewBag.Status = "Your account was activated";
        return  RedirectToAction("Index", "Home");
     //    return RedirectToAction("Index", "Home");
     //else
     //    return RedirectToAction("LogOn");
 }
Esempio n. 3
0
 //
 // GET: /User/Delete/5
 public ActionResult Delete(int id)
 {
     try
     {
         User userOwner = new UserRepository().GetDBUser(id);
         MailSender.SendMail(3, userOwner);
         var lotrep = new LotRepository().DeleteUserLots(id);
         _db.DeleteUser(id);
     }
     catch (Exception ex)
     {
         throw ex;
     }
     return RedirectToAction("Index");
 }
Esempio n. 4
0
        public ActionResult Delete(Lot review)
        {
            //  HttpUtility.HtmlEncode(id);
            Lot lot = lotrep.GetLot(review.Id);
            if (lot == null)
            {/// return RedirectToAction("Http404", "Error");
                throw new Exception("This lot doesn't exist!!!");
            }

            DeletePicture(lot.Picture);
            // послать сообщение об удалении
            User userOwner = new UserRepository().GetDBUser(lot.Owner_id);
            MailSender.SendMail(2, userOwner, lot);
            lotrep.DeleteLot(lot.Id);

            return RedirectToAction("Index", "Home");
        }
Esempio n. 5
0
        public ActionResult Create(Lot newLot, IEnumerable<HttpPostedFileBase> fileUpload)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    LoadPicture(fileUpload, ref newLot);
                    // TODO: Add insert logic here
                    var user_id = new UserRepository().GetDBUser(User.Identity.Name).user_id;
                    newLot.Owner_id = user_id;
                    var review = new LotRepository().InsertLot(newLot);

                    return RedirectToAction("Index", "Home");
                }
                catch
                {
                    return View(newLot);
                }
            }
            return View(newLot);
        }
Esempio n. 6
0
        public ActionResult Details(LotEditModel lot, FormCollection collection)
        {
            if (ModelState.IsValid)
            {
                var review = new LotRepository().GetLot(lot.Id);
                var oldCustomer = new UserRepository().GetDBUser(review.Customer_id);
                if (review.Customer_id != 0)
                {
                    MailSender.SendMail(5, oldCustomer, review);
                }

                var customer = new UserRepository().GetDBUser(User.Identity.Name);
                if (oldCustomer.user_id != customer.user_id)
                {
                    lotrep.SetPrice(lot.Id, lot.Price, customer.user_id);
                }
                else
                {
                    lotrep.SetPrice(lot.Id, lot.Price);
                }
                ViewBag.PriceValid = "You rate has been accepted";
            }
            var lotEdit = new LotRepository().GetLot(lot.Id);
            LotEditModel newreview = new LotEditModel(lotEdit);
            return View(newreview);
        }
Esempio n. 7
0
        public ActionResult RestorePassword(RestorePasswordModel model)
        {
            if (ModelState.IsValid)
            {
                if (model.UserName == Membership.GetUserNameByEmail(model.Email))
                {
                    var userRep = new UserRepository();
                    var user = userRep.GetDBUser(model.UserName);
                    userRep.ChangePassword(model.UserName);
                   var userNew = userRep.GetDBUser(model.UserName);
                   MailSender.SendMail(8, user);
                    ViewBag.message = "The message has been send to your e-mail";
                   return View();
                }
            }

                return View(model);
        }
Esempio n. 8
0
 //
 // GET: /User/
 public ActionResult Index()
 {
     var review = new UserRepository().GetAllUsers();
     return View(review);
 }
Esempio n. 9
0
 //
 // GET: /User/Details/5
 public ActionResult Details(int id)
 {
     var review = new UserRepository().GetDBUser(id);
     return View(review);
 }