Exemple #1
0
        public virtual ActionResult ChildCategoryAttributes([Bind(Prefix = "ThreadForm.AttributeValues")]  AttributeValueModel[] attributeValues, int attributeId)
        {
            var helper = new CategoryAttributeHelper();
            var categoryAttributeValues = helper.GetCategoryAttributeValues(attributeValues != null ? attributeValues.Where(cv => cv.AttributeId == attributeId) : new AttributeValueModel[0]);
            var allSubAttributes = categoryAttributeValues.SelectMany(cav => cav.Attribute.ChildAttributes);
            var selectedSubAttributes = allSubAttributes.Where(sa => categoryAttributeValues.Any(cav => cav.SelectedOptions.Intersect(sa.ParentOptions).Any()));

            var model = new CategoryAttributesThreadFormModel
                            {
                                CategoryAttributes = selectedSubAttributes.ToList(),
                                CategoryAttributeValues = attributeValues
                            };

            return PartialView(MVC.Thread.Views._CategoryAttributes, model);
        }
Exemple #2
0
        public virtual ActionResult ChildCategoryAttributes(
            [Bind(Prefix = "AttributeValues")] AttributeValueModel[] attributeValues, int attributeId)
        {
            var helper = new CategoryAttributeHelper();
            var categoryAttributeValues =
                helper.GetCategoryAttributeValues(attributeValues.Where(cv => cv.AttributeId == attributeId));
            var allSubAttributes = categoryAttributeValues.SelectMany(cav => cav.Attribute.ChildAttributes);
            var selectedSubAttributes =
                allSubAttributes.Where(
                    sa => categoryAttributeValues.Any(cav => cav.SelectedOptions.Intersect(sa.ParentOptions).Any()));

            var attributes =
                selectedSubAttributes.Where(
                    ca => ca.Type == CategoryAttributeType.MultiSelect || ca.Type == CategoryAttributeType.SingleSelect)
                    .ToList();

            var model = new KeywordProcessFormModel
                            {CategoryAttributes = attributes, CategoryAttributeValues = attributeValues};

            return PartialView(MVC.Catalog.Views._KeywordCategoryAttributes, model);
        }
Exemple #3
0
        public virtual ActionResult Save(ThreadForm form)
        {
            ThreadMemoryHelper.PopRememberedThread();

            if (!ModelState.IsValid)
            {
                
                Log.Info(GetType(),"Thread Save Validation Failed with errors: {0}",string.Join(";",ModelState.SelectMany(keyValuePair => keyValuePair.Value.Errors).Select(x => x.ErrorMessage)));
                return View(MVC.Thread.Views.Options, form);
            }

            var thread = Mapper.Map<Thread>(form);

            var helper = new CategoryAttributeHelper();
            var categoryAttributes = helper.GetCategoryAttributeValues(form.AttributeValues).ToList();
            foreach (var categoryAttributeValue in categoryAttributes)
                thread.CategoryAttributes.Add(categoryAttributeValue);

            thread.Author = AuthenticationHelper.CurrentUser;
            thread.Category = Repository.Category.Get(form.CategoryId.Value);

            if (form.CustomValue == null)
                thread.Value = Repository.Category.GetValue(form.CategoryId.Value, ThreadPriority.Medium, form.Verbosity);

            thread.Posts.First().Author = AuthenticationHelper.CurrentUser;
            thread.Posts.First().Type = PostType.Question;

            var brokerId = BrokerHelper.GetBrokerIdFromCookie();
            if (brokerId != null)
                thread.Broker = Repository.User.Get(brokerId.Value);

            Repository.Thread.Add(thread);
            
            if (form.DirectQuestionExpertId != null) { DirectQuestion(form.DirectQuestionExpertId.Value, thread.Id); }

            if (form.CustomValue != null) { EventLog.Event<UserDefinedPriceEvent>(thread); }

            form.PaymentForm.RelatedId = thread.Id;

            var attachmentsDirPath = HttpContext.Server.MapPath("~/Attachments/");
            if (Directory.Exists(attachmentsDirPath + form.TemporaryAttachmentFolder)) { MoveAttachmentsFromTemporaryFolder(form.TemporaryAttachmentFolder, thread.Id); }

            var provisionData = "\r\n" + "Prowizja eksperta: " + thread.ExpertProvision.ToString() + 
                "\r\n" + "Prowizja brokera: " + thread.BrokerProvision.ToString();
            EventLog.Event<NewThreadEvent>(thread, provisionData);

            var model = form.PaymentForm.PreparePayment(Url);

            if (model.ImmediateRedirectActionResult != null)
                return RedirectToAction(model.ImmediateRedirectActionResult);

            return View(MVC.Payment.Views.PaymentRedirect, model);
        }
Exemple #4
0
        private ActionResult GetChildCategoryAttributesActionResult(AttributeValueModel[] attributeValues, int attributeId)
        {
            var helper = new CategoryAttributeHelper();
            var categoryAttributeValues = helper.GetCategoryAttributeValues(attributeValues.Where(cv => cv.AttributeId == attributeId), true);
            var allSubAttributes = categoryAttributeValues.SelectMany(cav => cav.Attribute.ChildAttributes);
            var selectedSubAttributes = allSubAttributes.Where(sa => categoryAttributeValues.Any(cav => cav.SelectedOptions.Intersect(sa.ParentOptions).Any()));

            var attributes = selectedSubAttributes.Where(ca => ca.Type == CategoryAttributeType.MultiSelect || ca.Type == CategoryAttributeType.SingleSelect).ToList();

            var model = new ExpertCategoryAttributesModel
            {
                CategoryAttributes = attributes,
                CategoryAttributeValues = attributeValues
            };

            return PartialView(MVC.Account.Views._ExpertCategoryAttributes, model);
        }
Exemple #5
0
        public virtual ActionResult ExpertCategoryAttributes(int categoryId, IEnumerable<AttributeValueModel> attributeValues, string expertReason)
        {
            var currentExpert = AuthenticationHelper.CurrentUser.Expert;

            var helper = new CategoryAttributeHelper();
            var category = Repository.Category.Get(categoryId);
            var categoryAttributeValues = new ExpertCategoryAttributeValues { Category = category };

            categoryAttributeValues.CategoryAttributes.AddRange(helper.GetCategoryAttributeValues(attributeValues, true));
            categoryAttributeValues.ExpertReason = expertReason;
            
            var currentCategoryAttributeValues = currentExpert.CategoryAttributes.SingleOrDefault(c => c.Category.Id == categoryId);

            if (currentCategoryAttributeValues != null)
               currentExpert.CategoryAttributes.Remove(currentCategoryAttributeValues);

            currentExpert.CategoryAttributes.Add(categoryAttributeValues);
            Repository.Expert.Update(currentExpert);

            EventLog.ExpertQualificationChangedEvent(currentExpert.User, string.Format(Resources.Account.ExpertCategoryAttributesChanged, category.Name));

            return RedirectToAction(currentExpert.CategoryAttributes.Count < currentExpert.Categories.Count ? MVC.Account.ExpertCategoryAttributes() : MVC.Profile.Edit());
        }
Exemple #6
0
        public virtual ActionResult StoreKeyword([Bind(Prefix = "KeywordProcessForm")] KeywordProcessForm form)
        {
            var keyword = Repository.SEOKeyword.Get(form.SeoKeywordId);
            var category = Repository.Category.Get(form.CategoryId);

            keyword.Status = SEOKeywordStatus.Processed;
            keyword.Type = form.SeoKeywordType;
            keyword.Category = category;
            keyword.Phrase = form.SeoKeywordPhrase;

            var helper = new CategoryAttributeHelper();
            keyword.CategoryAttributes.Clear();
            keyword.CategoryAttributes.AddRange(helper.GetCategoryAttributeValues(form.AttributeValues));

            Repository.SEOKeyword.Update(keyword);

            Flash.Success(string.Format(Resources.Catalog.LandingPageCreated, keyword.Phrase));

            return RedirectToAction(MVC.Catalog.ProcessKeyword());
        }