コード例 #1
0
        public virtual ActionResult ContactUs(FormCollection formCollection)
        {
            var contact = new Contact();

            TryUpdateModel(contact, formCollection);

            contact.Description = formCollection["Descript"];
            contact.Telephone   = formCollection["Telephone"];
            contact.EMail       = formCollection["EMail"];
            contact.Subject     = formCollection["Subject"];
            contact.AddedDate   = DateTime.Now;
            contact.Active      = true;

            hopeLingerieEntities.Contacts.AddObject(contact);
            hopeLingerieEntities.SaveChanges();

            Mail mail = hopeLingerieEntities.Mails.SingleOrDefault(a => a.Code == "CONTACTUS");

            if (mail != null)
            {
                MailService.Send(mail.From, "*****@*****.**", mail.Subject, mail.Body);
            }

            return(View("Enviado"));
        }
コード例 #2
0
        public bool SubstractStock(List <OrderDetail> orderDetails, ref HopeLingerieEntities context)
        {
            if (stockValidate == null)
            {
                return(false);
            }

            foreach (var orderDetail in orderDetails)
            {
                var productId = orderDetail.ProductId;
                var colorId   = orderDetail.ColorId;
                var sizeId    = orderDetail.SizeId;
                var quantity  = orderDetail.Quantity;

                var stock = context.Stocks.SingleOrDefault(x => x.ProductId == productId && x.ColorId == colorId && x.SizeId == sizeId && x.Active);

                if (stock != null)
                {
                    stockValidate.SubstractStock(stock, quantity);

                    // Si el stock es negativo realiza el proceso pero genera un error y lo almacena en la base de datos.
                    if (!stockValidate.HasStock(stock))
                    {
                        context.ErrorLogs.AddObject(new ErrorLog {
                            AddedDate = DateTime.Now, Message = "Error: Producto " + orderDetail.ProductId + " tiene Stock Real NEGATIVO"
                        });
                        context.SaveChanges();
                        return(false);
                    }
                }
            }
            return(true);

            //     hopeLingerieEntities.SaveChanges();
        }
コード例 #3
0
        public ActionResult RecibeNewsLetter(FormCollection formCollection)
        {
            var step  = formCollection["Step"];
            var email = formCollection["receba_novidades"];

            var exists = (hopeLingerieEntities.NewsLetters.SingleOrDefault(x => x.Email == email && x.Active) != null) ? true : false;

            if (!exists)
            {
                hopeLingerieEntities.AddToNewsLetters(new NewsLetter {
                    Email = email, Active = true, Name = "", AddedDate = DateTime.Now
                });
                hopeLingerieEntities.SaveChanges();
            }

            return(RedirectToAction("GoStep", new { Step = step }));
        }
コード例 #4
0
        public bool ChangePassword(string email, string oldPassword, string newPassword)
        {
            ValidationUtil.ValidateRequiredStringValue(email, "email");
            ValidationUtil.ValidateRequiredStringValue(oldPassword, "oldPassword");
            ValidationUtil.ValidateRequiredStringValue(newPassword, "newPassword");

            try
            {
                Customer customer = hopeLingerieEntities.Customers.SingleOrDefault(x => x.Email == email && x.Active);

                if (customer == null)
                {
                    return(false);
                }

                var dbPassword = EncryptionService.Decrypt(customer.Password, KeyString);

                if (dbPassword != oldPassword)
                {
                    return(false);
                }

                customer.Password = EncryptionService.Encrypt(newPassword, KeyString);
                hopeLingerieEntities.SaveChanges();

                Mail mail = hopeLingerieEntities.Mails.SingleOrDefault(a => a.Code == "CHANGEPWD");

                if (mail != null)
                {
                    MailService.Send(mail.From, email, mail.Subject, String.Format(mail.Body, customer.FirstName + " " + customer.LastName, email, newPassword));
                }

                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
コード例 #5
0
        public virtual string RegisterNewsletter(string name, string email)
        {
            var newsLetter = hopeLingerieEntities.NewsLetters.SingleOrDefault(x => x.Email == email);

            if (newsLetter == null)
            {
                NewsLetter nl = new NewsLetter();
                nl.Active    = true;
                nl.AddedDate = DateTime.Now;
                nl.Email     = email;
                nl.Name      = name;
                hopeLingerieEntities.NewsLetters.AddObject(nl);
                hopeLingerieEntities.SaveChanges();
            }

            return("");
        }
コード例 #6
0
        public override void OnException(System.Web.Mvc.ExceptionContext filterContext)
        {
            base.OnException(filterContext);

            //OVERRIDE THE 500 ERROR
            filterContext.HttpContext.Response.StatusCode = 200;

            var errorLog = new ErrorLog {
                AddedDate  = System.DateTime.Now,
                StackTrace = filterContext.Exception.StackTrace,
                Message    = filterContext.Exception.Message
            };

            hopeLingerieEntities.ErrorLogs.AddObject(errorLog);

            hopeLingerieEntities.SaveChanges();
        }
コード例 #7
0
        // Este proceso corre en la home, obtiene todas las ventas en estado "En Proceso" e itera las mismas comparando su fecha-hora de creación con la actual.
        // Aquellas que superen el tiempo permitido serán pasada a estado "Cancelada" y se reintegrará su stock.
        public void PurgeOrders()
        {
            var      purgeMinutes  = Convert.ToInt16(ConfigurationManager.AppSettings["PurgeMinutes"]);
            DateTime purgeDateTime = DateTime.Now.AddMinutes(-1 * purgeMinutes);
            // Pendientes cuya fecha-hora de alta sea menor al tiempo definido por PurgeMinutes
            var orders       = hopeLingerieEntities.Orders.Where(x => x.OrderStatusId == 1 && x.AddedDate < purgeDateTime && x.Active);
            var stockService = new StockService(new VirtualStock());

            if (orders.Count() > 0)
            {
                foreach (var order in orders)
                {
                    // Verifica si existe en dineromail, si no existe Cancela la orden y recupera Stock Virtual
                    UpdateOrderStatus(order.OrderId.ToString(), ref hopeLingerieEntities);
                }

                hopeLingerieEntities.SaveChanges();
            }
        }
コード例 #8
0
        public virtual ActionResult ContactUs(FormCollection formCollection)
        {
            var contact = new Contact();

            TryUpdateModel(contact, formCollection);

            contact.NewsLetter  = (formCollection["NewsLetter"] != "N");
            contact.Description = formCollection["Descript"];
            contact.AddedDate   = DateTime.Now;
            hopeLingerieEntities.Contacts.AddObject(contact);

            if (contact.NewsLetter)
            {
                var newsLetter = new NewsLetter();
                newsLetter.Email     = contact.EMail;
                newsLetter.Name      = contact.Name;
                newsLetter.AddedDate = DateTime.Now;
                hopeLingerieEntities.NewsLetters.AddObject(newsLetter);
            }

            hopeLingerieEntities.SaveChanges();

            return(View("../Home/Index"));
        }
コード例 #9
0
        public virtual ActionResult Edit(Customer customer)
        {
            var emailExists = hopeLingerieEntities.Customers.SingleOrDefault(a => a.CustomerId != customer.CustomerId && a.Email == customer.Email && a.Active);

            if (emailExists != null)
            {
                TempData["Message"]    = "El Email ingresado ya existe en nuestra base de datos!";
                TempData["ActionType"] = ActionType.Back;

                return(Redirect("/Account/Information"));
            }

            var newCustomer = hopeLingerieEntities.Customers.SingleOrDefault(a => a.CustomerId == customer.CustomerId && a.Active);

            newCustomer.BirthDate  = customer.BirthDate;
            newCustomer.Cellular   = customer.Cellular;
            newCustomer.City       = customer.City;
            newCustomer.DNI        = customer.DNI;
            newCustomer.Fax        = customer.Fax;
            newCustomer.FirstName  = customer.FirstName;
            newCustomer.LastName   = customer.LastName;
            newCustomer.NewsLetter = customer.NewsLetter;
            newCustomer.Number     = customer.Number;
            newCustomer.StateId    = customer.StateId;
            newCustomer.Telephone1 = customer.Telephone1;
            newCustomer.Telephone2 = customer.Telephone2;
            newCustomer.Telephone3 = customer.Telephone3;
            newCustomer.ZipCode    = customer.ZipCode;
            newCustomer.Gender     = customer.Gender;
            newCustomer.Address    = customer.Address;

            if (!customer.NewsLetter)
            {
                var newsLetter = hopeLingerieEntities.NewsLetters.SingleOrDefault(x => x.Email == newCustomer.Email);
                hopeLingerieEntities.NewsLetters.DeleteObject(newsLetter);
            }
            else
            {
                var newsLetter = hopeLingerieEntities.NewsLetters.SingleOrDefault(x => x.Email == newCustomer.Email);

                if (newsLetter != null)
                {
                    newsLetter.Email = customer.Email;
                    newsLetter.Name  = customer.LastName + ", " + customer.FirstName;
                }
                else
                {
                    newsLetter           = new NewsLetter();
                    newsLetter.Email     = customer.Email;
                    newsLetter.Name      = customer.LastName + ", " + customer.FirstName;
                    newsLetter.AddedDate = DateTime.Now;
                    hopeLingerieEntities.NewsLetters.AddObject(newsLetter);
                }
            }

            // Si hay cambio de mail lo desloguea.
            if (newCustomer.Email != customer.Email)
            {
                newCustomer.Email = customer.Email;
                hopeLingerieEntities.SaveChanges();
                FormsService.SignOut();

                TempData["Message"]    = "Tu cuenta ha sido modificada con éxito! Al modificar el Email deberás ingresar nuevamente al sitio";
                TempData["ActionType"] = ActionType.Catalogue;
                return(Redirect("/Account/Information"));
            }

            hopeLingerieEntities.SaveChanges();
            TempData["Message"]    = "Tu cuenta ha sido modificada con éxito!";
            TempData["ActionType"] = ActionType.Catalogue;
            return(Redirect("/Account/Information"));
        }