Exemple #1
0
        private List<lnksalesorder> GetPendingSOItems(TTTEntities context, ShoppingBagIndexViewModel shoppingBagViewModel = null)
        {
            var soItemsA = new List<lnksalesorder>();
            var soItemsB = new List<lnksalesorder>();
            var salesOrderItems = new List<lnksalesorder>();

            var customerEmail = Util.GetCustomerEmail();

            if (!string.IsNullOrEmpty(customerEmail))
            {
                var openStatusID = Util.GetStatusID(Status.Open.ToString());

                var openSalesOrder = context.trnsalesorders.Where(a => a.Email == customerEmail && a.StatusID == openStatusID).SingleOrDefault();

                if (openSalesOrder != null)
                {
                    if (shoppingBagViewModel != null)
                        shoppingBagViewModel.SalesOrderID = openSalesOrder.ID;

                    soItemsA = context.lnksalesorders.Where(a => a.SalesOrderID == openSalesOrder.ID && a.Active).ToList();
                }
            }

            ConstructShoppingBagCookie();

            if (Request.Cookies[Util.GetShoppingBagCookieName()] != null)
            {
                soItemsB = context.lnksalesorders.Where(a => a.CookieID == cookieID && a.SalesOrderID == null && a.Active).ToList();
            }

            salesOrderItems = soItemsA.Union(soItemsB).ToList();

            return salesOrderItems;
        }
Exemple #2
0
        //
        // GET: /Admin/ColourPriority/

        public virtual ActionResult Index()
        {
            var viewModel = new ColourPriorityViewModel();

            using (var context = new TTTEntities())
            {
                var results = context.refcolours
                                     .GroupJoin(context.lnkcolourpriorities, a => a.ID, b => b.ColourID, (a, b) => new { Colour = a, priority = b })
                                     .Where(a => a.Colour.Active)
                                     .Select(a => new
                                     {
                                         ColourID = a.Colour.ID,
                                         ColourName = a.Colour.Name,
                                         Priority = a.priority.FirstOrDefault()
                                     }).OrderBy(a => a.Priority.Sequence).ToList();

                foreach (var result in results)
                {
                    viewModel.Priorities.Add(new ColourPriorityDetails()
                    {
                        ColourID = result.ColourID,
                        ColourName = result.ColourName,
                        Priority = result.Priority == null ? "" : result.Priority.Sequence.ToString()
                    });
                }
            }

            viewModel.Priorities = viewModel.Priorities.OrderBy(a => string.IsNullOrWhiteSpace(a.Priority)).ToList();

            return View(viewModel);
        }
Exemple #3
0
        private List<BaseRefModel> Search(BaseRefSearchCriteria criteria)
        {
            var results = new List<BaseRefModel>();

            using (var context = new TTTEntities())
            {
                var query = context.reflifestyles.AsQueryable();

                if (criteria.ID.HasValue && criteria.ID > 0)
                    query = query.Where(a => a.ID == criteria.ID.Value);

                if (!string.IsNullOrEmpty(criteria.Name))
                    query = query.Where(a => a.Name.ToLower().Trim() == criteria.Name.ToLower().Trim());

                if (criteria.Active.HasValue)
                    query = query.Where(a => a.Active == criteria.Active.Value);

                query = query.OrderBy(a => a.Name);

                results =
                    query.Select(a => new BaseRefModel
                    {
                        ID = a.ID,
                        Name = a.Name,
                        Active = a.Active
                    }).ToList();
            }

            return results;
        }
Exemple #4
0
        private ShoppingBagIndexViewModel ConstructShoppingBagViewModel()
        {
            var shoppingBagViewModel = new ShoppingBagIndexViewModel();

            using (var context = new TTTEntities())
            {
                var salesOrderItems = GetPendingSOItems(context, shoppingBagViewModel);

                if (salesOrderItems.Count > 0)
                {
                    var soItemIDs = salesOrderItems.Select(a => a.ID).ToList();

                    GetNormalModel(shoppingBagViewModel, soItemIDs, context);

                    GetCustomizeModel(shoppingBagViewModel, soItemIDs, context);
                }
            }

            shoppingBagViewModel.ShoppingBagItems.Any(a => string.IsNullOrEmpty(a.CookieID));

            shoppingBagViewModel.ShoppingBagItems = shoppingBagViewModel.ShoppingBagItems.OrderBy(a => a.CookieID).ToList();

            shoppingBagViewModel.GrandTotal = shoppingBagViewModel.ShoppingBagItems.Sum(a => a.Quantity * a.Price);

            return shoppingBagViewModel;
        }
Exemple #5
0
        public virtual ActionResult StatusResponse()
        {
            try
            {
                var viewModel = ConstructPaymentResponseModel();
                var log = ConstructLogPayment(viewModel);
                var salesOrderID = int.Parse(log.RefNo);
                var pendingStatusID = Util.GetStatusID(Status.Pending.ToString());                

                using (var context = new TTTEntities())
                {
                    context.logpayments.Add(log);
                    context.SaveChanges();

                    var salesOrder = context.trnsalesorders
                        .Include(a => a.refstatu)
                        .SingleOrDefault(a => a.ID == salesOrderID);

                    if (salesOrder == null)
                        throw new ApplicationException("Order not found.");
                    if (salesOrder.refstatu.Name != Status.Open.ToString())
                        throw new ApplicationException("Invalid order status.");

                    if (log.Status == Settings.Default.iPay88_Status_Success)
                    {
                        salesOrder.StatusID = pendingStatusID;
                        salesOrder.PaymentGatewayTransID = log.TransId;
                        salesOrder.UpdateDT = DateTime.Now;
                        context.SaveChanges();

                        var soItems =
                            context.lnksalesorders
                                .Where(a => a.Active && a.SalesOrderID == salesOrderID && a.ModelSizeID.HasValue)
                                .ToList();

                        foreach (var item in soItems)
                        {
                            var modelSize = context.lnkmodelsizes.Single(a => a.ID == item.ModelSizeID.Value);
                            modelSize.Quantity -= item.Quantity;
                        }

                        context.SaveChanges();

                        return RedirectToAction(MVC.Checkout.Success(salesOrderID));
                    }
                    else
                    {
                        var errMsg = string.Format("Payment failed for Sales Order ID:{0}. Error Description: {1}", 
                            salesOrderID, log.ErrDesc);

                        throw new ApplicationException(errMsg);
                    }
                }
            }
            catch (Exception ex)
            {
                LogException(ex);
                return RedirectException(ex);
            }            
        }
Exemple #6
0
        public virtual ActionResult Index()
        {
            var categories = new List<refcategory>();
            var type = CategoryType.Shoes.ToString();

            using (var context = new TTTEntities())
            {
                categories = context.refcategories.Where(a => a.Active && a.Type == type).ToList();
            }

            return View(categories);
        }
Exemple #7
0
        private List<OrderStatusSearchResult> SearchOrder(OrderStatusSearchCriteria criteria)
        {
            var results = new List<OrderStatusSearchResult>();
            var excludeStatus = new string[] { Status.Open.ToString(), Status.Closed.ToString() };

            using (var context = new TTTEntities())
            {
                var query =
                    (from a in context.trnsalesorders
                     join b in context.logpayments on a.PaymentGatewayTransID equals b.TransId
                    where !excludeStatus.Contains(a.refstatu.Name)
                        && b.Status == Settings.Default.iPay88_Status_Success
                    select new { SalesOrder = a, LogPayment = b }).AsQueryable();

                if (criteria.SalesOrderID.HasValue && criteria.SalesOrderID.Value > 0)
                    query = query.Where(a => a.SalesOrder.ID == criteria.SalesOrderID.Value);

                if (criteria.StatusID > 0)
                    query = query.Where(a => a.SalesOrder.StatusID == criteria.StatusID);

                if (criteria.PaymentSuccessDateFrom.HasValue)
                {
                    var fromDate = criteria.PaymentSuccessDateFrom.Value.Date.AddMilliseconds(-1);

                    query = query.Where(a => a.LogPayment.CreateDT > fromDate);
                }

                if (criteria.PaymentSuccessDateTo.HasValue)
                {
                    var toDate = criteria.PaymentSuccessDateTo.Value.Date.AddDays(1);

                    query = query.Where(a => a.LogPayment.CreateDT < toDate);
                }

                query = query.OrderByDescending(a => a.SalesOrder.ID)
                             .Take(50);

                results =
                    query.Select(a => new OrderStatusSearchResult
                    {
                        Email = a.SalesOrder.Email,
                        PaymentSuccessDate = a.LogPayment.CreateDT,
                        SalesOrderID = a.SalesOrder.ID,
                        Status = a.SalesOrder.refstatu.Name
                    }).ToList();
            }

            return results;
        }
Exemple #8
0
        private WishlistIndexViewModel ConstructWishistIndexViewModel(int id = 0)
        {
            var viewModel = new WishlistIndexViewModel()
            {
                WishlistID = id
            };

            using (var context = new TTTEntities())
            {
                GetNormalModel(viewModel, context);

                GetCustomizeModel(viewModel, context);
            }

            return viewModel;
        }
Exemple #9
0
        private void ActivateVoucher(VoucherMaintainViewModel viewModel, List<string> stringCodes)
        {
            var codeFrom = viewModel.CodeFrom.PadLeft(Properties.Settings.Default.VoucherLength, '0');
            var codeTo = viewModel.CodeTo.PadLeft(Properties.Settings.Default.VoucherLength, '0');

            using (var context = new TTTEntities())
            {
                var results = context.tblvouchers
                                      .GroupJoin(context.trnsalesorders, a => a.ID, b => b.VoucheID, (a, b) => new { voucher = a, so = b })
                                      .Where(a => String.Compare(codeFrom, a.voucher.Code) <= 0 && String.Compare(a.voucher.Code, codeTo) <= 0)
                                      .Select(a => new
                                      {
                                          Voucher = a.voucher,
                                          SO = a.so.FirstOrDefault()
                                      }).ToList();

                var oldCodes = results.Where(a => a.SO == null).Select(a => a.Voucher.Code).ToList();
                var newCodes = stringCodes.Except(oldCodes).ToList();

                var oldVouchers = context.tblvouchers.Where(a => oldCodes.Contains(a.Code)).ToList();
                foreach (var voucher in oldVouchers)
                {
                    voucher.Value = viewModel.Value;
                    voucher.Active = true;
                    voucher.UpdateDT = DateTime.Now;
                }

                foreach (var code in newCodes)
                {
                    context.tblvouchers.Add(new tblvoucher()
                    {
                        Active = true,
                        Code = code.PadLeft(Properties.Settings.Default.VoucherLength, '0'),
                        CreateDT = DateTime.Now,
                        Type = "Cash",
                        Value = viewModel.Value,
                    });
                }

                context.SaveChanges();
            }
        }
Exemple #10
0
        private ShoeColourViewModel CnstructShoeColourViewModel(int customizeModelID, int heelHeight = 0)
        {
            var viewModel = new ShoeColourViewModel();

            using (var context = new TTTEntities())
            {
                var shoeStyle = context.refcustomizemodels.Where(a => a.ID == customizeModelID).Single();
                viewModel.Name = shoeStyle.Name;
                viewModel.Style = shoeStyle.Style;
                viewModel.Type = shoeStyle.Type;
                viewModel.Price = shoeStyle.Price;
                viewModel.HeelHeight = 3;
                viewModel.CustomizeModelID = shoeStyle.ID;

                viewModel.Items = context.lnkcustomizemodelimages
                                        .Where(a => a.CustomizeModelID == customizeModelID && (a.HeelHeight==heelHeight || heelHeight == 0))
                                        .OrderBy(a => a.Priority).ToList();
            }

            return viewModel;
        }
Exemple #11
0
        public virtual ActionResult Index(SignInViewModel viewModel, string returnUrl)
        {
            if (viewModel.RegisterViewModel == null)
                viewModel.RegisterViewModel = new SignInRegisterViewModel { ReturnUrl = returnUrl };
            viewModel.ReturnUrl = returnUrl;

            if (!ModelState.IsValid)
                return View(viewModel);

            var pwd = Util.GetMD5Hash(viewModel.Password.Trim());

            using (var context = new TTTEntities())
            {
                var user = 
                    context.tblaccesses
                        .SingleOrDefault(a => a.Email == viewModel.Email && 
                                              a.Password == pwd && 
                                              a.Active);

                if (user == null)
                {
                    ModelState.AddModelError("LoginForm", "Invalid Email/Password.");
                    return View(viewModel);
                }

                if (!user.ConfirmedEmail)
                {
                    var verifyEmailModel = new VerifyEmailViewModel { User = user, AfterLogin = true };
                    return View(MVC.SignIn.Views.VerifyEmail, verifyEmailModel);
                }

                Util.SessionAccess = user;
                FormsAuthentication.SetAuthCookie(viewModel.Email, false);
            }

            LinkToAccount();

            return RedirectToLocal(viewModel.ReturnUrl);
        }
Exemple #12
0
        private List<CategoryModel> Search(CategorySearchCriteria criteria)
        {
            var results = new List<CategoryModel>();

            using (var context = new TTTEntities())
            {
                var query = context.refcategories.AsQueryable();

                if (criteria.ID.HasValue && criteria.ID > 0)
                    query = query.Where(a => a.ID == criteria.ID.Value);

                if (!string.IsNullOrEmpty(criteria.Name))
                    query = query.Where(a => a.Name.ToLower().Trim() == criteria.Name.ToLower().Trim());

                if (!string.IsNullOrEmpty(criteria.Type))
                    query = query.Where(a => a.Type == criteria.Type);

                if (!string.IsNullOrEmpty(criteria.Image))
                    query = query.Where(a => a.Name.ToLower().Trim().Contains(criteria.Image.ToLower().Trim()));

                if (criteria.Active.HasValue)
                    query = query.Where(a => a.Active == criteria.Active.Value);

                query = query.OrderBy(a => a.Name);

                results =
                    query.Select(a => new CategoryModel
                    {
                        ID = a.ID,
                        Name = a.Name,
                        Active = a.Active,
                        Type = a.Type,
                        Image = a.Image
                    }).ToList();
            }

            return results;
        }
Exemple #13
0
        public virtual ActionResult Index(VoucherSearchViewModel viewModel, FormCollection collection)
        {
            if (collection["submit"].ToString() == "Maintain Voucher")
                return RedirectToAction("Maintain");

            using (var context = new TTTEntities())
            {
                var query = context.tblvouchers
                                     .GroupJoin(context.trnsalesorders, a => a.ID, b => b.VoucheID, (a, b) => new { vouher = a, so = b })
                                     .Select(a => new
                                     {
                                         Voucher = a.vouher,
                                         SO = a.so.FirstOrDefault()
                                     });

                if (!string.IsNullOrEmpty(viewModel.CodeFrom))
                    query = query.Where(a => String.Compare(viewModel.CodeFrom, a.Voucher.Code) <= 0);


                if (!string.IsNullOrEmpty(viewModel.CodeTo))
                    query = query.Where(a => String.Compare(a.Voucher.Code, viewModel.CodeTo) <= 0);

                var results = query.ToList();

                foreach (var result in results)
                {
                    viewModel.Results.Add(new VoucherDetails()
                    {
                        Active = result.Voucher.Active,
                        Code = result.Voucher.Code,
                        OrderID = result.SO == null ? "" : result.SO.ID.ToString(),
                        Value = result.Voucher.Value
                    });
                }
            }

            return View(viewModel);
        }
Exemple #14
0
        public virtual ActionResult Index(ColourPriorityViewModel viewModel, FormCollection collection)
        {
            using (var context = new TTTEntities())
            {
                var Colours = context.refcolours.Where(a => a.Active).ToList();

                //var ColourPriorities = context.lnkcolourpriorities.Where(a => a.ColourID).SingleOrDefault();

                foreach (var Colour in Colours)
                {
                    var ColourPriority = context.lnkcolourpriorities.Where(a => a.ColourID == Colour.ID).SingleOrDefault();

                    if (collection[string.Format("txt_{0}", Colour.ID)].ToString() != "")
                    {
                        if (ColourPriority != null)
                            ColourPriority.Sequence = Convert.ToInt16(collection[string.Format("txt_{0}", Colour.ID)]);
                        else
                            context.lnkcolourpriorities.Add(new lnkcolourpriority()
                            {
                                Active = true,
                                CreateDT = DateTime.Now,
                                ColourID = Colour.ID,
                                Sequence = Convert.ToInt16(collection[string.Format("txt_{0}", Colour.ID)])
                            });
                    }
                    else
                    {
                        if (ColourPriority != null)
                            context.lnkcolourpriorities.Remove(ColourPriority);
                    }
                }

                context.SaveChanges();
            }

            return RedirectToAction("Index");
        }
Exemple #15
0
        public virtual ActionResult ShoeStyle()
        {
            var viewModel =new CustomizeViewModels();
            var results = new List<refcustomizemodel>();

            using (var context = new TTTEntities())
            {
                results = context.refcustomizemodels.ToList();
            }

            var styles = results.Select(a => a.Style).Distinct().ToList();
            foreach (var style in styles)
            {
                var customizeModels = new CustomizeModels()
                {
                     Style = style,
                     Items = results.Where(a => a.Style == style).ToList()
                };

                viewModel.CustomizeModelsList.Add(customizeModels);
            }

            return View(viewModel);
        }
Exemple #16
0
        public virtual ActionResult ShoeDetails(string sku)
        {
            var viewModel = new ShoeDetailsViewModel();

            using (var context = new TTTEntities())
            {
                viewModel.ModelImage = context.lnkcustomizemodelimages.Where(a => a.SKU == sku).Single();
                viewModel.CustomizeModel = context.refcustomizemodels.Where(a => a.ID == viewModel.ModelImage.CustomizeModelID).Single();
            }

            viewModel.ShareUrl = string.Format("http://www.tote-to-toe.com/Customize/ShoeDetails?sku={0}", sku);
                

            string imgName = string.Format("{0}_{1}_{2}_{3}_{4}.jpg",
                                            viewModel.CustomizeModel.Style,
                                            viewModel.CustomizeModel.Type,
                                            viewModel.ModelImage.HeelHeight,
                                            viewModel.ModelImage.Colour,
                                            viewModel.ModelImage.Priority);
            ConstructRecentViewCookie(string.Format("Customize/ShoeColour/{0}", imgName),
                                        string.Format("/Customize/ShoeDetails?sku={0}", sku));

            return View(viewModel);
        }
Exemple #17
0
        public virtual ActionResult Edit(MaintainModelViewModel viewModel)
        {
            using (var trans = new TransactionScope())
            {
                using (var context = new TTTEntities())
                {
                    var model = context.refmodels.Where(a => a.ID == viewModel.ModelID).Single();
                    var modelColourDesc = context.lnkmodelcolourdescs.Where(a => a.ID == viewModel.ModelColourDescID).Single();
                    var brandID = context.refbrands.Where(a => a.Name == viewModel.BrandName && a.CategoryID == viewModel.CategoryID).Single().ID;

                    // Model details****************************************************
                    model.BrandID = brandID;
                    model.Price = viewModel.Price;
                    model.DiscountPrice = viewModel.DiscountPrice;
                    // *****************************************************************

                    // Model colour description details*****************************************
                    modelColourDesc.Active = viewModel.Active;
                    modelColourDesc.SKU = viewModel.SKU;
                    modelColourDesc.HeelHeight = viewModel.HeelHeight;
                    modelColourDesc.Style = viewModel.Style;
                    modelColourDesc.Description = viewModel.Description;
                    modelColourDesc.LiningSock = viewModel.LiningSock;
                    modelColourDesc.Sole = viewModel.Sole;
                    modelColourDesc.Make = viewModel.Make;
                    modelColourDesc.UpperMaterial = viewModel.UpperMaterial;
                    modelColourDesc.HeelDesc = viewModel.HeelDesc;
                    // ***************************************************************************

                    // Model lifestyle************************************************************
                    var selectedLifestyleIDs = viewModel.SelectedLifestyleIDText.Replace(",,",",").Split(',').Select(int.Parse).ToList();
                    var selectedLifeStyles = context.reflifestyles.Where(a => selectedLifestyleIDs.Contains(a.ID)).ToList();
                    var modelLifestyles = context.lnkmodellifestyles.Where(a => a.ModelID == viewModel.ModelID &&
                                                                           a.ColourDescID == viewModel.ColourDescID).ToList();
                    modelLifestyles.ForEach(a => { a.Active = false; a.UpdateDT = DateTime.Now; });

                    foreach (var lifeStyle in selectedLifeStyles)
                    {
                        var modelLifestyle = modelLifestyles.Where(a => a.LifeStyleID == lifeStyle.ID).SingleOrDefault();

                        if (modelLifestyle != null)
                        {
                            modelLifestyle.Active = true;
                            modelLifestyle.UpdateDT = DateTime.Now;
                        }
                        else
                        {
                            context.lnkmodellifestyles.Add(new lnkmodellifestyle()
                            {
                                 ColourDescID = viewModel.ColourDescID,
                                 ModelID = viewModel.ModelID,
                                 Active=true,
                                 CreateDT=DateTime.Now,
                                 LifeStyleID=lifeStyle.ID,
                            }); 
                        }
                    }
                    //********************************************************************************

                    // Model trend********************************************************************************
                    var selectedTrendIDs = viewModel.SelectedTrendIDText.Replace(",,", ",").Split(',').Select(int.Parse).ToList();
                    var selectedTrends = context.reftrends.Where(a => selectedTrendIDs.Contains(a.ID)).ToList();
                    var modelTrends = context.lnkmodeltrends.Where(a => a.ModelID == viewModel.ModelID &&
                                                                        a.ColourDescID == viewModel.ColourDescID).ToList();
                    modelTrends.ForEach(a => { a.Active = false; a.UpdateDT = DateTime.Now; });

                    foreach (var trend in selectedTrends)
                    {
                        var modelTrend = modelTrends.Where(a => a.TrendID == trend.ID).SingleOrDefault();

                        if (modelTrend != null)
                        {
                            modelTrend.Active = true;
                            modelTrend.UpdateDT = DateTime.Now;
                        }
                        else
                        {
                            context.lnkmodeltrends.Add(new lnkmodeltrend()
                            {
                                ColourDescID = viewModel.ColourDescID,
                                ModelID = viewModel.ModelID,
                                Active = true,
                                CreateDT = DateTime.Now,
                                TrendID = trend.ID,
                            });
                        }
                    }
                    // ************************************************************************************************

                    context.SaveChanges();
                }

                trans.Complete();
            }

            return RedirectToAction("Edit", new { id = viewModel.ModelColourDescID });
        }
Exemple #18
0
        public virtual ActionResult BackendResponse()
        {
            try
            {
                var viewModel = ConstructPaymentResponseModel();
                var log = ConstructLogPayment(viewModel);
                var salesOrderID = int.Parse(log.RefNo);
                var pendingStatusID = Util.GetStatusID(Status.Pending.ToString());

                using (var context = new TTTEntities())
                {
                    context.logpayments.Add(log);
                    context.SaveChanges();

                    var salesOrder = context.trnsalesorders
                        .Include(a => a.refstatu)
                        .SingleOrDefault(a => a.ID == salesOrderID);

                    if (salesOrder == null)
                        throw new ApplicationException("Order not found.");

                    if (salesOrder.refstatu.Name == Status.Open.ToString())
                    {
                        if (log.Status == Settings.Default.iPay88_Status_Success)
                        {
                            salesOrder.StatusID = pendingStatusID;
                            salesOrder.PaymentGatewayTransID = log.TransId;
                            salesOrder.UpdateDT = DateTime.Now;
                            context.SaveChanges();

                            var soItems =
                            context.lnksalesorders
                                .Where(a => a.Active && a.SalesOrderID == salesOrderID && a.ModelSizeID.HasValue)
                                .ToList();

                            foreach (var item in soItems)
                            {
                                var modelSize = context.lnkmodelsizes.Single(a => a.ID == item.ModelSizeID.Value);
                                modelSize.Quantity -= item.Quantity;
                            }

                            context.SaveChanges();
                        }
                    }
                    else
                    {
                        if(string.IsNullOrEmpty(salesOrder.PaymentGatewayTransID))
                            throw new ApplicationException("Invalid order status.");
                    }                    
                }
            }
            catch (Exception ex)
            {
                LogException(ex);
                throw;
            }

            return Content("RECEIVEOK");
        }
Exemple #19
0
        public virtual ActionResult Update(OrderStatusViewModel viewModel)
        {
            var updateModel = viewModel.UpdateModel;

            using (var context = new TTTEntities())
            {
                var salesOrder = context.trnsalesorders
                    .Include(a => a.refstatu)
                    .Single(a => a.ID == updateModel.SalesOrderID);
                var status = salesOrder.refstatu.Name;
                var processingStatus = Status.Processing.ToString();
                var deliveryStatus = Status.Delivery.ToString();
                var closedStatus = Status.Closed.ToString();

                if (status == Status.Pending.ToString())
                {
                    salesOrder.StatusID = context.refstatus.Single(a => a.Name == processingStatus && a.Active).ID;
                }
                else if (status == processingStatus)
                {
                    salesOrder.StatusID = context.refstatus.Single(a => a.Name == deliveryStatus && a.Active).ID;
                    salesOrder.DeliveryDT = updateModel.DeliveryDT;
                }
                else if (status == deliveryStatus)
                {
                    salesOrder.StatusID = context.refstatus.Single(a => a.Name == closedStatus && a.Active).ID;
                    salesOrder.DeliveryDT = updateModel.DeliveryDT;
                }

                context.SaveChanges();
            }

            return RedirectToAction(MVC.Admin.OrderStatus.Index());
        }
Exemple #20
0
        public virtual ActionResult GetColourDescByColour(int colourID, int colourDescID)
        {
            var selectListItem = new List<SelectListItem>();

            using (var context = new TTTEntities())
            {
                var colourDescs = context.refcolourdescs.Where(a => a.ColourID == colourID).ToList();

                selectListItem = colourDescs.Select(a =>
                new SelectListItem()
                {
                    Text = a.Name,
                    Value = a.ID.ToString(),
                    Selected = colourDescID == a.ID ? true : false
                }).ToList();

                selectListItem.Insert(0, new SelectListItem() { Value = "", Text = "ACTUAL COLOUR" });
            }

            return Json(selectListItem);
        }
Exemple #21
0
        public virtual ActionResult GetBrandByCategory(int categoryID, string brandName)
        {
            var selectListItem = new List<SelectListItem>();

            using (var context = new TTTEntities())
            {
                var brandNames = context.refbrands.Where(a => a.CategoryID == categoryID).Select(a => a.Name).Distinct().ToList();

                selectListItem = brandNames.Select(a =>
                new SelectListItem()
                {
                    Text = a,
                    Value = a,
                    Selected = brandName == a ? true : false
                }).ToList();

                selectListItem.Insert(0, new SelectListItem() { Value = "", Text = "BRAND" });
            }

            return Json(selectListItem);
        }
Exemple #22
0
        public virtual ActionResult UploadImage(ModelImageViewModel viewModel, HttpPostedFileBase fileMain, HttpPostedFileBase fileSub,
            HttpPostedFileBase fileThumbnail1, HttpPostedFileBase fileThumbnail2, HttpPostedFileBase fileThumbnail3, HttpPostedFileBase fileThumbnail4,
            HttpPostedFileBase fileImage1, HttpPostedFileBase fileImage2, HttpPostedFileBase fileImage3, HttpPostedFileBase fileImage4)
        {
            try
            {
                using (var context = new TTTEntities())
                {
                    var modelColourDesc = context.lnkmodelcolourdescs.Where(a => a.ID == viewModel.ModelColourDescID).Single();
                    var modelImages = context.lnkmodelimages.Where(a => a.ModelColourDescID == viewModel.ModelColourDescID).ToList();

                    if (fileMain != null)
                    {
                        SaveImage(viewModel, fileMain);
                        modelColourDesc.MainImage = Path.GetFileName(fileMain.FileName);
                    }

                    if (fileSub != null)
                    {
                        SaveImage(viewModel, fileSub);
                        modelColourDesc.SubImage = Path.GetFileName(fileSub.FileName);
                    }

                    for (int i = 0; i < 4; i++)
                    {
                        var modelImage = new lnkmodelimage()
                        {
                            CreateDT = DateTime.Now,
                            Active = true,
                            ModelColourDescID = viewModel.ModelColourDescID,
                        };

                        //existing model images
                        if (modelImages.Count() > i)
                            modelImage = modelImages[i];

                        switch (i)
                        {
                            case 0:
                                UploadModelImage(viewModel, fileThumbnail1, fileImage1, modelImage);
                                break;
                            case 1:
                                UploadModelImage(viewModel, fileThumbnail2, fileImage2, modelImage);
                                break;
                            case 2:
                                UploadModelImage(viewModel, fileThumbnail3, fileImage3, modelImage);
                                break;
                            case 3:
                                UploadModelImage(viewModel, fileThumbnail4, fileImage4, modelImage);
                                break;
                        }

                        // new model images
                        if (modelImage.ID == 0)
                            context.lnkmodelimages.Add(modelImage);

                    }
                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return RedirectToAction("Edit", new { id = viewModel.ModelColourDescID }); 
        }
Exemple #23
0
        public virtual ActionResult UploadImage(int modelID, int colourDescID, int categoryID)
        {
            var modelImageViewModel = new ModelImageViewModel()
            {
                ModelID = modelID,
                ColourDescID = colourDescID
            };

            using (var context = new TTTEntities())
            {
                modelImageViewModel.ModelImages = context.lnkmodelimages
                                                         .Join(context.lnkmodelcolourdescs, a => a.ModelColourDescID, b => b.ID, 
                                                                    (a, b) => new { modelColourDesc = b, modelImage = a })
                                                         .Where(a => a.modelColourDesc.ModelID == modelID && a.modelColourDesc.ColourDescID == colourDescID)
                                                         .Select(a => a.modelImage)
                                                         .OrderBy(a=>a.ID)
                                                         .ToList();

                var modelColourDesc = context.lnkmodelcolourdescs
                                             .Where(a => a.ModelID == modelID && a.ColourDescID == colourDescID)
                                             .Single();

                modelImageViewModel.CategoryName = context.refcategories.Where(a => a.ID == categoryID).Single().Name;

                modelImageViewModel.ModelImages = context.lnkmodelimages.Where(a => a.ModelColourDescID == modelColourDesc.ID).ToList();

                modelImageViewModel.ModelID = modelColourDesc.ModelID;
                modelImageViewModel.ModelColourDescID = modelColourDesc.ID;
                modelImageViewModel.MainImage = string.Format("~/Images/{0}/{1}", modelImageViewModel.CategoryName, modelColourDesc.MainImage);
                modelImageViewModel.SubImage = string.Format("~/Images/{0}/{1}", modelImageViewModel.CategoryName, modelColourDesc.SubImage);
            }

            return View(modelImageViewModel);
        }
Exemple #24
0
        public virtual ActionResult Edit(int id)
        {
            var maintainViewModel = new MaintainModelViewModel();

            using (var context = new TTTEntities())
            {
                //var results = context.refmodels
                //    .Join(context.refbrands, a => a.BrandID, b => b.ID, (a, b) => new { Model = a, Brand = b })
                //    .Join(context.refcategories, a => a.Brand.CategoryID, b => b.ID, (a, b) => new { ModelBrand = a, Category = b })
                //    .Join(context.lnkmodelcolourdescs, a => a.ModelBrand.Model.ID, b => b.ModelID, (a, b) => new { ModelBrandCategory = a, ModelColourDesc = b })
                //    .Join(context.refcolourdescs, a => a.ModelColourDesc.ColourDescID, b => b.ID, (a, b) => new { ModelBrandCategoryColourDesc = a, ColourDesc = b })
                //    .GroupJoin(context.lnkmodeltrends, a=>a.ModelBrandCategoryColourDesc.ModelBrandCategory.ModelBrand.Model.ID, b=>b.ModelID,
                //            (a, b) => new { ModelBrandCategoryColourDescTrends = a, ModelTrend = b })
                //    .GroupJoin(context.lnkmodellifestyles, a => a.ModelBrandCategoryColourDescTrends.ModelBrandCategoryColourDesc.ModelBrandCategory.ModelBrand.Model.ID, b => b.ModelID,
                //            (a, b) => new { ModelBrandCategoryColourDescTrendLifestyle = a, ModelLifestyle = b })
                //    .Select(a => new
                //    {
                //        Model = a.ModelBrandCategoryColourDescTrendLifestyle.ModelBrandCategoryColourDescTrends.ModelBrandCategoryColourDesc.ModelBrandCategory.ModelBrand.Model,
                //        Brand = a.ModelBrandCategoryColourDescTrendLifestyle.ModelBrandCategoryColourDescTrends.ModelBrandCategoryColourDesc.ModelBrandCategory.ModelBrand.Brand,
                //        Category = a.ModelBrandCategoryColourDescTrendLifestyle.ModelBrandCategoryColourDescTrends.ModelBrandCategoryColourDesc.ModelBrandCategory.Category,
                //        ColourDesc = a.ModelBrandCategoryColourDescTrendLifestyle.ModelBrandCategoryColourDescTrends.ColourDesc,
                //        ModelColourDesc = a.ModelBrandCategoryColourDescTrendLifestyle.ModelBrandCategoryColourDescTrends.ModelBrandCategoryColourDesc.ModelColourDesc,
                //        ModelTrend = a.ModelBrandCategoryColourDescTrendLifestyle.ModelTrend,
                //        ModelLifestyle = a.ModelLifestyle
                //    })
                //    .Where(a => a.ModelColourDesc.ID == id)
                //    .ToList();

                var results = context.lnkmodelcolourdescs
                                     .Join(context.refmodels, a => a.ModelID, b => b.ID, (a, b) => new { ModelColourDesc = a, Model = b })
                                     .Join(context.refcolourdescs, a => a.ModelColourDesc.ColourDescID, b => b.ID,
                                            (a, b) => new { a.ModelColourDesc, a.Model, ColourDesc = b })
                                     .Join(context.refbrands, a => a.Model.BrandID, b => b.ID,
                                            (a, b) => new { a.ModelColourDesc, a.Model, a.ColourDesc, Brand = b })
                                     .Join(context.refcategories, a => a.Brand.CategoryID, b => b.ID,
                                            (a, b) => new { a.ModelColourDesc, a.Model, a.ColourDesc, a.Brand, Category = b })
                                     .GroupJoin(context.lnkmodeltrends, a => new { a.ModelColourDesc.ModelID, a.ModelColourDesc.ColourDescID },
                                            b => new { b.ModelID, b.ColourDescID },
                                            (a, b) => new { a.ModelColourDesc, a.Model, a.ColourDesc, a.Brand, a.Category, ModelTrends = b })
                                     .GroupJoin(context.lnkmodellifestyles, a => new { a.ModelColourDesc.ModelID, a.ModelColourDesc.ColourDescID },
                                            b => new { b.ModelID, b.ColourDescID },
                                            (a, b) => new { a.ModelColourDesc, a.Model, a.ColourDesc, a.Brand, a.Category, a.ModelTrends, ModelLifestyles = b })
                                     .Where(a => a.ModelColourDesc.ID == id)
                                     .ToList();

                var modelDetails = results.First();

                var trendIDs = results.Select(a => a.ModelTrends).First().Count() > 0 ?
                                        results.Select(a => a.ModelTrends).First().Where(b => b.Active).Select(c => c.TrendID).Distinct().ToList() :
                                        new List<int>();
                var lifestyleIDs = results.Select(a => a.ModelLifestyles).First().Count() > 0 ?
                                        results.Select(a => a.ModelLifestyles).First().Where(b => b.Active).Select(c => c.LifeStyleID).Distinct().ToList() :
                                    new List<int>();

                maintainViewModel = new MaintainModelViewModel()
                {
                    ModelColourDescID = id,
                    BrandID = modelDetails.Brand.ID,
                    BrandName = modelDetails.Brand.Name,
                    CategoryID = modelDetails.Category.ID,
                    ModelID = modelDetails.Model.ID,
                    ModelName = modelDetails.Model.Name,
                    ColourDescID = modelDetails.ColourDesc.ID,
                    ColourID = modelDetails.ColourDesc.ColourID,
                    Description = modelDetails.ModelColourDesc.Description,
                    DiscountPrice = modelDetails.Model.DiscountPrice == null ? 0 : modelDetails.Model.DiscountPrice.Value,
                    Price = modelDetails.Model.Price,
                    HeelDesc = modelDetails.ModelColourDesc.HeelDesc,
                    Sole = modelDetails.ModelColourDesc.Sole,
                    LiningSock = modelDetails.ModelColourDesc.LiningSock,
                    Make = modelDetails.ModelColourDesc.Make,
                    Style = modelDetails.ModelColourDesc.Style,
                    UpperMaterial = modelDetails.ModelColourDesc.UpperMaterial,
                    HeelHeight = modelDetails.ModelColourDesc.HeelHeight,
                    SKU = modelDetails.ModelColourDesc.SKU,
                    SelectedTrend = trendIDs,
                    SelectedTrendIDText = string.Format("0,{0}", string.Join(",", trendIDs)),
                    SelectedLifestyle = lifestyleIDs,
                    SelectedLifestyleIDText = string.Format("0,{0}", string.Join(",", lifestyleIDs)),
                    AvailableLifestyles = context.reflifestyles.Where(a => a.Active).ToList(),
                    AvailableTrends = context.reftrends.Where(a => a.Active).ToList(),
                    Active = modelDetails.Model.Active
                };
            }

            return View(maintainViewModel);

        }
Exemple #25
0
        public virtual ActionResult Index(ModelViewModel viewModel)
        {
            using (var context = new TTTEntities())
            {
                var query = context.refmodels
                    .Join(context.refbrands, a => a.BrandID, b => b.ID, (a, b) => 
                        new { Model = a, Brand = b })
                    .Join(context.refcategories, a => a.Brand.CategoryID, b => b.ID, (a, b) => 
                        new { a.Model, a.Brand, Category = b })
                    .Join(context.lnkmodelcolourdescs, a => a.Model.ID, b => b.ModelID, (a, b) => 
                        new { a.Model, a.Brand, a.Category, ModelColourDesc = b })
                    .Join(context.refcolourdescs, a => a.ModelColourDesc.ColourDescID, b => b.ID, (a, b) => 
                        new { a.Model,a.Brand,a.Category,a.ModelColourDesc, ColourDesc = b })
                    .Join(context.refcolours, a => a.ColourDesc.ColourID, b => b.ID, (a, b) =>
                        new { a.Model, a.Brand, a.Category, a.ModelColourDesc, a.ColourDesc, Colour = b })
                    .Take(50)
                    .OrderByDescending(a => a.Model.UpdateDT)
                    .ThenByDescending(a => a.Model.CreateDT)
                    .Select(a => new
                    {
                        ModelColourDescID = a.ModelColourDesc.ID,
                        ColourDescID = a.ColourDesc.ID,
                        ColourDescName = a.ColourDesc.Name,
                        ModelName = a.Model.Name,
                        ModelID = a.Model.ID,
                        BrandName = a.Brand.Name,
                        CategoryName = a.Category.Name,
                        CategoryID = a.Category.ID,
                        ColourName = a.Colour.Name,
                        ColourID = a.Colour.ID,
                        Active = a.Model.Active

                        //Model = a.Model,
                        //Brand = a.Brand,
                        //Category = a.Category,
                        //ColourDesc = a.ColourDesc,
                        //ModelColourDesc = a.ModelColourDesc
                    });

                if (viewModel.CategoryID != 0)
                    query = query = query.Where(a => a.CategoryID == viewModel.CategoryID);

                if (viewModel.BrandName!="0" && !string.IsNullOrEmpty(viewModel.BrandName))
                    query = query = query.Where(a => a.BrandName == viewModel.BrandName);

                if (viewModel.ColourID != 0)
                    query = query.Where(a => a.ColourID == viewModel.ColourID);

                if (viewModel.ColourDescID.HasValue)
                    query = query.Where(a => a.ColourDescID == viewModel.ColourDescID.Value || viewModel.ColourDescID.Value == 0);

                if (viewModel.ModelID != 0)
                  query =  query.Where(a => a.ModelID == viewModel.ModelID);

                if (viewModel.Active.HasValue)
                  query =  query.Where(a => a.Active == viewModel.Active.Value);

                var models = query.ToList();

                foreach (var model in models)
                {
                    viewModel.ModelDetails.Add(new ModelDetails()
                    {
                        ModelColourDescID = model.ModelColourDescID,
                        ColourDescID = model.ColourDescID,
                        ModelName = model.ModelName,
                        ModelID = model.ModelID,
                        BrandName = model.BrandName,
                        CategoryName = model.CategoryName,
                        ColourName = model.ColourName,
                        ColourDescName = model.ColourDescName,
                        Active = model.Active
                    });
                }
            }

            return View(viewModel);
        }
Exemple #26
0
        public virtual ActionResult Edit(int id)
        {
            ValidateIsAdmin();

            using (var context = new TTTEntities())
            {
                var record = context.reflifestyles.Single(a => a.ID == id);

                var viewModel = new BaseRefCreateUpdateViewModel
                {
                    ControllerName = "LifeStyle",
                    Active = record.Active,
                    ID = record.ID,
                    Name = record.Name
                };

                return View(MVC.Admin.Shared.Views.BaseRefEdit, viewModel);
            }

        }
Exemple #27
0
        public virtual ActionResult Edit(BaseRefCreateUpdateViewModel viewModel)
        {
            ValidateIsAdmin();

            using (var context = new TTTEntities())
            {
                var record = context.reflifestyles.Single(a => a.ID == viewModel.ID);

                record.Name = viewModel.Name;
                record.Active = viewModel.Active;

                context.SaveChanges();
            }

            return RedirectToAction(MVC.Admin.LifeStyle.Index());
        }
Exemple #28
0
        public virtual ActionResult Size(int modelID, int colourDescID)
        {
            var modelSizeViewModel = new ModelSizeViewModel()
            {
                ModelID = modelID,
                ColourDescID = colourDescID
            };

            using (var context = new TTTEntities())
            {
                modelSizeViewModel.ModelSizes = context.lnkmodelsizes.Where(a => a.ModelID == modelID && a.ColourDescID == colourDescID).ToList();
                modelSizeViewModel.ModelColourDescID = context.lnkmodelcolourdescs.Where(a => a.ModelID == modelID && a.ColourDescID == colourDescID).First().ID;
            }

            //35|5|2|4,8
            var beginSize = Convert.ToInt16((Properties.Settings.Default.InitialSize.Split(',')[0]).Split('|')[0]);
            var sizeRange = Convert.ToInt16((Properties.Settings.Default.InitialSize.Split(',')[1]));

            for (var i = beginSize; i <= beginSize + sizeRange; i++)
                modelSizeViewModel.AvailableSize.Add(i.ToString());

            return View(modelSizeViewModel);
        }
Exemple #29
0
        public virtual ActionResult Create(BaseRefCreateUpdateViewModel viewModel)
        {
            ValidateIsAdmin();

            using (var context = new TTTEntities())
            {
                var newRecord = new reflifestyle
                {
                    Active = viewModel.Active,
                    Name = viewModel.Name,
                    CreateDT = DateTime.Now
                };

                context.reflifestyles.Add(newRecord);
                context.SaveChanges();
            }

            return RedirectToAction(MVC.Admin.LifeStyle.Index());
        }
Exemple #30
0
        public virtual ActionResult Size(ModelSizeViewModel viewModel, FormCollection collection)
        {
            using (var trans = new TransactionScope())
            {
                using (var context = new TTTEntities())
                {
                    var modelSizes = context.lnkmodelsizes
                                           .Where(a => a.ModelID == viewModel.ModelID && a.ColourDescID == viewModel.ColourDescID)
                                           .ToList();

                    var beginSize = Convert.ToInt16((Properties.Settings.Default.InitialSize.Split(',')[0]).Split('|')[0]);
                    var sizeRange = Convert.ToInt16((Properties.Settings.Default.InitialSize.Split(',')[1]));

                    for (var i = beginSize; i <= beginSize + sizeRange; i++)
                    {
                        var modelSize = modelSizes.Where(a => a.Size == i.ToString()).SingleOrDefault();

                        if (modelSize == null)
                        {
                            context.lnkmodelsizes.Add(new lnkmodelsize()
                            {
                                ModelID = viewModel.ModelID,
                                ColourDescID = viewModel.ColourDescID,
                                Active = true,
                                CreateDT = DateTime.Now,
                                Size = i.ToString(),
                                Quantity = Convert.ToInt32(collection[string.Format("txt_{0}", i.ToString())])
                            });
                        }
                        else
                        {
                            modelSize.Quantity = Convert.ToInt32(collection[string.Format("txt_{0}", modelSize.Size)]);
                            modelSize.UpdateDT = DateTime.Now;
                        }
                    }

                    context.SaveChanges();
                }

                trans.Complete();
            }

            return RedirectToAction("Edit", new { id = viewModel.ModelColourDescID });
        }