Esempio n. 1
0
 public CreateOrUpdateSpecificPriceModalViewModel(GetProductSpecificPriceForEditOutput output)
 {
     output.MapTo <GetProductSpecificPriceForEditOutput, CreateOrUpdateSpecificPriceModalViewModel>(this);
 }
Esempio n. 2
0
        public async Task <PartialViewResult> CreateOrUpdateSpecificPriceModal(long productId, long?id = null)
        {
            int? nullable;
            bool flag;
            bool flag1;
            ISpecificPriceAppService specificPriceAppService = this._specificPriceAppService;
            NullableIdInput <long>   nullableIdInput         = new NullableIdInput <long>()
            {
                Id = id
            };
            GetProductSpecificPriceForEditOutput productSpecificPriceForEdit = await specificPriceAppService.GetProductSpecificPriceForEdit(nullableIdInput);

            CreateOrUpdateSpecificPriceModalViewModel createOrUpdateSpecificPriceModalViewModel = new CreateOrUpdateSpecificPriceModalViewModel(productSpecificPriceForEdit);
            Product product = await this._productAppService.GetProduct(productId);

            createOrUpdateSpecificPriceModalViewModel.BaseCost       = new decimal?(product.FinalPrice);
            createOrUpdateSpecificPriceModalViewModel.QuantitySoldIn = product.QuantitySoldIn;
            if (productSpecificPriceForEdit.SpecificPrice.ForCustomerId.HasValue)
            {
                ICustomerAppService customerAppService = this._customerAppService;
                GetCustomersInput   getCustomersInput  = new GetCustomersInput()
                {
                    MaxResultCount = 1,
                    Sorting        = "FirstName",
                    SkipCount      = 0
                };
                long value = productSpecificPriceForEdit.SpecificPrice.ForCustomerId.Value;
                getCustomersInput.Filter = string.Concat("id:", value.ToString());
                PagedResultOutput <CustomerListDto> customers = await customerAppService.GetCustomers(getCustomersInput);

                createOrUpdateSpecificPriceModalViewModel.CurrentlySelectedCustomerName = string.Concat(customers.Items[0].FullName, " - ", customers.Items[0].Email);
            }
            List <SelectListItem> selectListItems = new List <SelectListItem>();

            using (HttpClient httpClient = new HttpClient())
            {
                UrlHelper url = this.Url;
                nullable = (createOrUpdateSpecificPriceModalViewModel.SpecificPrice.ForCountryId.HasValue ? createOrUpdateSpecificPriceModalViewModel.SpecificPrice.ForCountryId : new int?(0));
                string str = url.RouteUrl("DefaultApiWithAction", new { httproute = "", controller = "Generic", action = "GetCountriesAsSelectListItems", countryId = 0, selectedCountryId = nullable }, this.Request.Url.Scheme);
                using (HttpResponseMessage async = await httpClient.GetAsync(str))
                {
                    if (async.IsSuccessStatusCode)
                    {
                        string str1 = await async.Content.ReadAsStringAsync();

                        selectListItems = JsonConvert.DeserializeObject <List <SelectListItem> >(str1);
                    }
                }
            }
            List <SelectListItem> selectListItems1 = selectListItems;
            SelectListItem        selectListItem   = new SelectListItem()
            {
                Text     = "",
                Value    = "",
                Disabled = false
            };

            selectListItems1.Insert(0, selectListItem);
            this.ViewData["Countries"] = selectListItems.AsEnumerable <SelectListItem>();
            List <OrganizationUnitDto> organizationUnitsByProperty = await this._organizationUnitAppService.GetOrganizationUnitsByProperty("SpecificPricesEnabled", "true");

            List <SelectListItem> selectListItems2 = new List <SelectListItem>();

            foreach (OrganizationUnitDto organizationUnitDto in organizationUnitsByProperty)
            {
                List <SelectListItem> selectListItems3 = selectListItems2;
                SelectListItem        selectListItem1  = new SelectListItem();
                string displayName = organizationUnitDto.DisplayName;
                int    memberCount = organizationUnitDto.MemberCount;
                selectListItem1.Text     = string.Format("{0} ({1} {2})", displayName, memberCount.ToString(), this.L("OUMemberCount"));
                selectListItem1.Value    = organizationUnitDto.Id.ToString();
                selectListItem1.Disabled = false;
                selectListItem1.Group    = null;
                flag = (!createOrUpdateSpecificPriceModalViewModel.SpecificPrice.ForOrganizationalUnitId.HasValue || createOrUpdateSpecificPriceModalViewModel.SpecificPrice.ForOrganizationalUnitId.Value != organizationUnitDto.Id ? false : true);
                selectListItem1.Selected = flag;
                selectListItems3.Add(selectListItem1);
            }
            SelectListItem selectListItem2 = new SelectListItem()
            {
                Text     = "",
                Value    = "",
                Disabled = false
            };

            selectListItems2.Insert(0, selectListItem2);
            this.ViewData["OrganizationUnits"] = selectListItems2.AsEnumerable <SelectListItem>();
            IRepository <ProductOption, long> repository = this._productOptionRepository;
            List <ProductOption> allListAsync            = await repository.GetAllListAsync((ProductOption x) => x.ProductId == product.Id && x.IsActive);

            List <ProductOption>  productOptions   = allListAsync;
            List <SelectListItem> selectListItems4 = new List <SelectListItem>();

            foreach (ProductOption productOption in productOptions)
            {
                List <SelectListItem> selectListItems5 = selectListItems4;
                SelectListItem        selectListItem3  = new SelectListItem()
                {
                    Text     = productOption.Name,
                    Value    = productOption.Id.ToString(),
                    Disabled = false,
                    Group    = null
                };
                flag1 = (!createOrUpdateSpecificPriceModalViewModel.SpecificPrice.ProductOptionId.HasValue || createOrUpdateSpecificPriceModalViewModel.SpecificPrice.ProductOptionId.Value != productOption.Id ? false : true);
                selectListItem3.Selected = flag1;
                selectListItems5.Add(selectListItem3);
            }
            SelectListItem selectListItem4 = new SelectListItem()
            {
                Text     = "",
                Value    = "",
                Disabled = false
            };

            selectListItems4.Insert(0, selectListItem4);
            this.ViewData["ProductOptions"] = selectListItems4.AsEnumerable <SelectListItem>();
            return(this.PartialView("_CreateOrUpdateSpecificPriceModal", createOrUpdateSpecificPriceModalViewModel));
        }