Esempio n. 1
0
        public ActionResult EditAttributeValue(int attrValueId = -1)
        {
            AttributeValueInfo attributeValueInfo = AdminCategories.GetAttributeValueById(attrValueId);

            if (attributeValueInfo == null)
            {
                return(PromptView("属性值不存在"));
            }
            if (attributeValueInfo.IsInput == 1)
            {
                return(PromptView("输入型属性值不能修改"));
            }

            AttributeValueModel model = new AttributeValueModel();

            model.AttrValue    = attributeValueInfo.AttrValue;
            model.DisplayOrder = attributeValueInfo.AttrValueDisplayOrder;

            AttributeInfo attributeInfo = Categories.GetAttributeById(attributeValueInfo.AttrId);

            ViewData["attrId"]        = attributeInfo.AttrId;
            ViewData["attributeName"] = attributeInfo.Name;
            ViewData["referer"]       = ShopUtils.GetAdminRefererCookie();

            return(View(model));
        }
Esempio n. 2
0
        private void GetAttributeValues()
        {
            AttributeModel             objAttributeIdAttributeModel = (AttributeModel)dAttributeName.SelectedItem;
            List <AttributeValueModel> lAttributeValueModel         = new List <AttributeValueModel>();

            if (objAttributeIdAttributeModel != null)
            {
                lAttributeValueModel = objDataAccess.GetAttributeValueByAttributeId(objAttributeIdAttributeModel.AttributeId);
            }

            AttributeModel             objParentAttributeModel    = (AttributeModel)ddlParentAttributes.SelectedItem;
            List <AttributeValueModel> lParentAttributeValueModel = objDataAccess.GetAttributeValueByAttributeId(objParentAttributeModel.AttributeId);

            var parentAttributeGridData = lAttributeValueModel.Join(lParentAttributeValueModel, p => p.ParentValue, q => q.Id, (p, q) => new { ParentAttributeId = q.Id, ParentAttributeName = q.Name, AttributeId = p.Id, AttributeName = p.Name });
            List <NewAttributeGrid> lNewAttributeGrid = new List <NewAttributeGrid>();

            foreach (var item in parentAttributeGridData)
            {
                AttributeValueModel objAttributeValueModel = lParentAttributeValueModel.Where(p => p.Id == item.ParentAttributeId).SingleOrDefault();
                lNewAttributeGrid.Add(new NewAttributeGrid()
                {
                    ParentAttributeValueModel = objAttributeValueModel,
                    AttributeId   = item.AttributeId,
                    AttributeName = item.AttributeName
                });
            }

            dGridNewAttributes.ItemsSource = lNewAttributeGrid;
        }
Esempio n. 3
0
        public ActionResult EditAttributeValue(AttributeValueModel model, int attrValueId = 0)
        {
            AttributeValueInfo attributeValueInfo = AdminCategories.GetAttributeValueById(attrValueId);

            if (attributeValueInfo == null)
            {
                return(PromptView("属性值不存在"));
            }
            //if (attributeValueInfo.IsInput == 1)
            //    return PromptView("输入型属性值不能修改");

            int attrValueId2 = AdminCategories.GetAttributeValueIdByAttrIdAndValue(attributeValueInfo.AttrId, model.AttrValue);

            if (attrValueId2 > 0 && attrValueId2 != attrValueId)
            {
                ModelState.AddModelError("AttrValue", "值已经存在");
            }

            if (ModelState.IsValid)
            {
                attributeValueInfo.AttrValue             = model.AttrValue;
                attributeValueInfo.AttrValueDisplayOrder = model.DisplayOrder;
                AdminCategories.UpdateAttributeValue(attributeValueInfo);
                AddMallAdminLog("修改属性值", "修改属性值,属性值ID为:" + attrValueId);
                return(PromptView("属性值修改成功"));
            }

            AttributeInfo attributeInfo = Categories.GetAttributeById(attributeValueInfo.AttrId);

            ViewData["attrId"]        = attributeInfo.AttrId;
            ViewData["attributeName"] = attributeInfo.Name;
            ViewData["referer"]       = MallUtils.GetMallAdminRefererCookie();

            return(View(model));
        }
Esempio n. 4
0
 public ActionResult CreateValue(AttributeValueModel model)
 {
     if (ModelState.IsValid)
     {
         var entity = model.MapTo <AttributeValue>();
         _attributeService.InsertAttributeValue(entity);
         return(AbpJson("ok"));
     }
     return(AbpJson("error"));
 }
Esempio n. 5
0
        private void EventSetter_OnHandler(object sender, MouseButtonEventArgs e)
        {
            object source   = e.OriginalSource;
            string isDelete = ((DataGridCell)sender).Column.Header.ToString().ToUpperInvariant();

            if (source.GetType() == typeof(Image) && isDelete == "DELETE")
            {
                DataGridRow deletedSelectedRow = FindParent <DataGridRow>(sender as DependencyObject);

                if (deletedSelectedRow.DataContext.GetType().Name == nameof(NewAttributeGrid))
                {
                    // Delete the sub attribute Value
                    NewAttributeGrid        objDeleteSelectedAttributeValueModel = (NewAttributeGrid)deletedSelectedRow.DataContext;
                    List <NewAttributeGrid> lNewAttributeGrid = (List <NewAttributeGrid>)dGridNewAttributes.ItemsSource;

                    if (objDeleteSelectedAttributeValueModel.AttributeId > 0)
                    {
                        AttributeValueModel objAttributeValueModel = new AttributeValueModel()
                        {
                            Id = objDeleteSelectedAttributeValueModel.AttributeId, Name = objDeleteSelectedAttributeValueModel.AttributeName
                        };
                        bool isResult = objDataAccess.DeleteAttributeValue(objAttributeValueModel);
                        if (isResult)
                        {
                            lNewAttributeGrid.Remove(objDeleteSelectedAttributeValueModel);
                            dGridNewAttributes.ItemsSource = null;
                            dGridNewAttributes.ItemsSource = lNewAttributeGrid;
                            MessageBox.Show(objDeleteSelectedAttributeValueModel.AttributeName + " Deleted Successfully");
                        }
                    }
                }
                else if (deletedSelectedRow.DataContext.GetType().Name == nameof(AttributeValueModel))
                {
                    // Delete the attribute Value
                    AttributeValueModel        objDeleteSelectedAttributeValueModel = (AttributeValueModel)deletedSelectedRow.DataContext;
                    List <AttributeValueModel> lAttributeValueModel = (List <AttributeValueModel>)dGridNewAttributes.ItemsSource;
                    if (objDeleteSelectedAttributeValueModel.Id > 0)
                    {
                        bool isResult = objDataAccess.DeleteAttributeValue(objDeleteSelectedAttributeValueModel);
                        if (isResult)
                        {
                            lAttributeValueModel.Remove(objDeleteSelectedAttributeValueModel);
                            dGridNewAttributes.ItemsSource = null;
                            dGridNewAttributes.ItemsSource = lAttributeValueModel;
                            MessageBox.Show(objDeleteSelectedAttributeValueModel.Name + " Deleted Successfully");
                        }
                    }
                }
            }
        }
Esempio n. 6
0
        public ActionResult AddAttributeValue(int attrId = -1)
        {
            AttributeInfo attributeInfo = AdminCategories.GetAttributeById(attrId);

            if (attributeInfo == null)
            {
                return(PromptView("属性不存在"));
            }

            AttributeValueModel model = new AttributeValueModel();

            ViewData["attrId"]        = attributeInfo.AttrId;
            ViewData["attributeName"] = attributeInfo.Name;
            ViewData["referer"]       = ShopUtils.GetAdminRefererCookie();
            return(View(model));
        }
Esempio n. 7
0
        public List <AttributeValueModel> GetChildAttributeValues(int parentAttributeValueId)
        {
            List <AttributeValueModel> attribValues = new List <AttributeValueModel>();

            attribValues.Add(new AttributeValueModel(-1, "Select"));
            var values = jmdc.GetChildAttributeValues(parentAttributeValueId);

            foreach (GetChildAttributeValuesResult jm in values)
            {
                AttributeValueModel ma = new AttributeValueModel();
                ma.Id   = jm.Id;
                ma.Name = jm.Name;
                attribValues.Add(ma);
            }
            return(attribValues);
        }
Esempio n. 8
0
        public bool DeleteAttributeValue(AttributeValueModel attributeValueModel)
        {
            bool isResult = true;

            try
            {
                AttributeValue deleteAttributeValue = jmdc.AttributeValues.Where(p => p.Id == attributeValueModel.Id).SingleOrDefault();
                jmdc.AttributeValues.DeleteOnSubmit(deleteAttributeValue);
                jmdc.SubmitChanges();
            }
            catch (Exception ex)
            {
                isResult = false;
                throw ex;
            }
            return(isResult);
        }
Esempio n. 9
0
        public async Task <BaseResult> CreateOrUpdate(AttributeValueModel model, int updateBy = 0, string updateByUserName = "")
        {
            var AttributeValue = model.ToAttributeValue();

            //Cập nhật thông tin chung của thực thể
            AttributeValue = AttributeValue.UpdateCommonInt(updateBy, updateByUserName);

            if (AttributeValue.Id > 0)
            {
                //Cập nhật
                return(await Update(AttributeValue));
            }
            else
            {
                //Thêm mới
                return(await Create(AttributeValue));
            }
        }
Esempio n. 10
0
        public ActionResult AddAttributeValue(AttributeValueModel model, int attrId = -1)
        {
            AttributeInfo attributeInfo = AdminCategories.GetAttributeById(attrId);

            if (attributeInfo == null)
            {
                ModelState.AddModelError("AttributName", "属性不存在");
            }

            if (AdminCategories.GetAttributeValueIdByAttrIdAndValue(attrId, model.AttrValue) > 0)
            {
                ModelState.AddModelError("AttributName", "值已经存在");
            }


            if (ModelState.IsValid)
            {
                AttributeGroupInfo attributeGroupInfo = AdminCategories.GetAttributeGroupById(attributeInfo.AttrGroupId);
                AttributeValueInfo attributeValueInfo = new AttributeValueInfo();

                attributeValueInfo.AttrId           = attributeInfo.AttrId;
                attributeValueInfo.AttrName         = attributeInfo.Name;
                attributeValueInfo.AttrDisplayOrder = attributeInfo.DisplayOrder;
                attributeValueInfo.AttrShowType     = attributeInfo.ShowType;

                attributeValueInfo.AttrGroupId           = attributeGroupInfo.AttrGroupId;
                attributeValueInfo.AttrGroupName         = attributeGroupInfo.Name;
                attributeValueInfo.AttrGroupDisplayOrder = attributeGroupInfo.DisplayOrder;

                attributeValueInfo.AttrValue             = model.AttrValue;
                attributeValueInfo.IsInput               = 0;
                attributeValueInfo.AttrValueDisplayOrder = model.DisplayOrder;

                AdminCategories.CreateAttributeValue(attributeValueInfo);
                AddAdminOperateLog("添加属性值", "添加属性值,属性值为:" + model.AttrValue);
                return(PromptView("属性值添加成功"));
            }
            ViewData["attrId"]        = attributeInfo.AttrId;
            ViewData["attributeName"] = attributeInfo.Name;
            ViewData["referer"]       = ShopUtils.GetAdminRefererCookie();
            return(View(model));
        }
Esempio n. 11
0
 public AttributeValueModel AddAttributeValue(AttributeValueModel objAttributeModel)
 {
     try
     {
         int?           iParentId         = objAttributeModel.ParentValue == 0 ? null : (int?)objAttributeModel.ParentValue;
         AttributeValue objAttributeValue = new AttributeValue()
         {
             AttributeId = objAttributeModel.AttributeId, Name = objAttributeModel.Name, ParentValue = iParentId
         };
         jmdc.AttributeValues.InsertOnSubmit(objAttributeValue);
         jmdc.SubmitChanges();
         objAttributeModel.AttributeId = objAttributeValue.AttributeId;
         objAttributeModel.Name        = objAttributeValue.Name;
         objAttributeModel.Id          = objAttributeValue.Id;
         objAttributeModel.ParentValue = objAttributeValue.ParentValue == null ? 0 : (int)objAttributeValue.ParentValue;
         return(objAttributeModel);
     }
     catch (Exception)
     {
         return(null);
     }
 }
Esempio n. 12
0
        public BaseResponse <PageListPortal <RestaurantSearchViewModel> > Search(RestaurantSearchModel searchModel)
        {
            try
            {
                if (searchModel == null)
                {
                    return(BaseResponse <PageListPortal <RestaurantSearchViewModel> > .NotFound(new PageListPortal <RestaurantSearchViewModel>(Enumerable.Empty <RestaurantSearchViewModel>().AsQueryable(), searchModel.PageIndex, searchModel.PageSize), message : "searchModel variable is null", fullMsg : ""));
                }

                searchModel.BusinessDay = searchModel.BusinessDay ?? "";
                var sortString = !string.IsNullOrEmpty(searchModel.SortString)
                ? searchModel.SortString
                : "RestaurantName DESC";

                searchModel.PageIndex = searchModel.PageIndex > 0 ? searchModel.PageIndex : 1;
                searchModel.PageSize  = searchModel.PageSize > 0 ? searchModel.PageSize : 10;
                string searchCity           = string.IsNullOrWhiteSpace(searchModel.City) ? "\"\"" : "\"" + searchModel.City.Trim() + "\"";
                string searchZoneDistrict   = string.IsNullOrWhiteSpace(searchModel.ZoneDistrict) ? "\"\"" : "\"" + searchModel.ZoneDistrict.Trim() + "\"";
                string searchRestaurantName = string.IsNullOrWhiteSpace(searchModel.RestaurantName) ? "\"\"" : "\"" + searchModel.RestaurantName.Trim() + "\"";
                string extendFilter         = string.Empty;

                #region Attribute define
                var listCuisine  = new List <int>();
                var listSuitable = new List <int>();
                var listServing  = new List <int>();
                if (searchModel.AttributeFid != null && searchModel.AttributeFid.Count > 0)
                {
                    List <AttributeValueModel> attributeList = new List <AttributeValueModel>();
                    foreach (string attItem in searchModel.AttributeFid)
                    {
                        if (!string.IsNullOrEmpty(attItem))
                        {
                            string[] arrResponse = attItem.Split('_');
                            if (arrResponse.Count() > 1)
                            {
                                int categoryId = string.IsNullOrEmpty(arrResponse[0]) != true?int.Parse(arrResponse[0]) : 0;

                                AttributeValueModel attributeItem = new AttributeValueModel {
                                    CategoryId = string.IsNullOrEmpty(arrResponse[0]) != true?int.Parse(arrResponse[0]) : 0, AttributeValue = string.IsNullOrEmpty(arrResponse[1]) != true?int.Parse(arrResponse[1]) : 0
                                };
                                attributeList.Add(attributeItem);
                            }
                        }
                    }
                    listCuisine  = (attributeList.Where(k => k.CategoryId == (int)AttributeEnum.Cuisines).Select(x => x.AttributeValue)).ToList();
                    listServing  = (attributeList.Where(k => k.CategoryId == (int)AttributeEnum.Servings).Select(x => x.AttributeValue)).ToList();
                    listSuitable = (attributeList.Where(k => k.CategoryId == (int)AttributeEnum.SuitableFor).Select(x => x.AttributeValue)).ToList();
                }

                #endregion



                var query = (_searchContext.Restaurants
                             .Where(
                                 k => k.Deleted == false && k.ActiveForOperation == true &&
                                 (listCuisine.Count() == 0 || (listCuisine.Count() > 0 && k.AttributeValues.Any(l => l.AttributeCategoryFid == (int)AttributeEnum.Cuisines && listCuisine.Contains(l.AttributeFid)))) &&
                                 (listServing.Count() == 0 || (listServing.Count() > 0 && k.AttributeValues.Any(l => l.AttributeCategoryFid == (int)AttributeEnum.Servings && listServing.Contains(l.AttributeFid)))) &&
                                 (listSuitable.Count() == 0 || (listSuitable.Count() > 0 && k.AttributeValues.Any(l => l.AttributeCategoryFid == (int)AttributeEnum.SuitableFor && listSuitable.Contains(l.AttributeFid)))) &&
                                 (string.IsNullOrWhiteSpace(searchModel.City) || (!string.IsNullOrWhiteSpace(searchModel.City) && k.City == searchModel.City.Trim())) &&
                                 (string.IsNullOrWhiteSpace(searchModel.ZoneDistrict) || (!string.IsNullOrWhiteSpace(searchModel.ZoneDistrict) && k.ZoneDistrict == searchModel.ZoneDistrict.Trim())) &&
                                 (string.IsNullOrWhiteSpace(searchModel.RestaurantName) || (!string.IsNullOrWhiteSpace(searchModel.RestaurantName) && k.RestaurantName.StartsWith(searchModel.RestaurantName.Trim())))
                                 //&& (k.ServingDining == searchModel.ServingType

                                 )
                             .Select(k => new RestaurantSearchViewModel()
                {
                    Id = k.Id
                    ,
                    UniqueId = k.UniqueId
                    ,
                    RestaurantName = k.RestaurantName
                    ,
                    IsBusinessDay = _searchContext.GetfnIsBusinessDayOperation(k.Id, searchModel.BusinessDay.Trim() ?? "")
                    ,
                    CuisineName = _searchContext.GetCuisines(k.Id, 1) ?? ""
                    ,
                    City = k.City ?? ""
                    ,
                    ZoneDistrict = k.ZoneDistrict ?? ""
                    ,
                    Country = k.Country ?? ""
                    ,
                    StartingPrice = k.StartingPrice
                    ,
                    CultureCode = k.CultureCode ?? ""
                    ,
                    CurrencyCode = k.CurrencyCode ?? ""
                    ,
                    FileStreamId = _searchContext.GetfnRestaurantImageIDVal(k.Id, 4),
                    ServingDining = k.ServingDining,
                    ServingVenue = k.ServingVenue
                })).OrderBy(sortString);
                return(BaseResponse <PageListPortal <RestaurantSearchViewModel> > .Success(new PageListPortal <RestaurantSearchViewModel>(query, searchModel.PageIndex, searchModel.PageSize)));
            }
            catch (Exception ex)
            {
                return(BaseResponse <PageListPortal <RestaurantSearchViewModel> > .InternalServerError(new PageListPortal <RestaurantSearchViewModel>(Enumerable.Empty <RestaurantSearchViewModel>().AsQueryable(), searchModel.PageIndex, searchModel.PageSize), message : ex.Message, fullMsg : ex.StackTrace));
            }
        }
Esempio n. 13
0
        private void bAddAttribute_Click(object sender, RoutedEventArgs e)
        {
            JobManager.DAL.DataAccess objDataAccess = new JobManager.DAL.DataAccess();

            // 1. Attribute Insertion

            int iAttributeId = 0;
            int iAttributeTypeSelectedValue = Convert.ToInt32(ddlAttributeType.SelectedValue);
            int iParentId = Convert.ToInt32(ddlParentAttributes.SelectedValue);

            if (dAttributeName.SelectedValue == null)
            {
                AttributeModel objAttributeModel = new AttributeModel();
                objAttributeModel.AttributeName   = dAttributeName.Text;
                objAttributeModel.AttributeTypeId = iAttributeTypeSelectedValue;
                objAttributeModel.ParentId        = iParentId;
                objDataAccess.AddAttribute(objAttributeModel);
                iAttributeId = objAttributeModel.AttributeId;
                MessageBox.Show("Attribute Added Successfully");
                LoadAttributes();
            }
            else
            {
                iAttributeId = Convert.ToInt32(dAttributeName.SelectedValue);
            }

            if (iAttributeId != 0)
            {
                // if user selects "select option"
                if (iAttributeTypeSelectedValue == 2)
                {
                    List <NewAttributeGrid> lAttributeGrid = new List <NewAttributeGrid>();
                    lAttributeGrid = (List <NewAttributeGrid>)dGridNewAttributes.ItemsSource;
                    List <AttributeValueModel> lAttributeValueModel = new List <AttributeValueModel>();

                    // 2. Parent Column Insertion
                    foreach (NewAttributeGrid itemNewAttributeGrid in lAttributeGrid)
                    {
                        if (itemNewAttributeGrid.ParentAttributeValueId == 0)
                        {
                            AttributeValueModel objAttributeValueModel = new AttributeValueModel();
                            objAttributeValueModel.Name        = itemNewAttributeGrid.ParentValue;
                            objAttributeValueModel.AttributeId = iAttributeId;

                            // Insert into Database  and assign the value to Grid again
                            objAttributeValueModel = objDataAccess.AddAttributeValue(objAttributeValueModel);
                            itemNewAttributeGrid.ParentAttributeValueId = objAttributeValueModel.Id;
                        }
                    }


                    /* Check whether the row is modified or not*/
                    foreach (NewAttributeGrid itemNewAttributeGrid in lAttributeGrid)
                    {
                        bool bIsmodified = (itemNewAttributeGrid.CurrentAttribute != itemNewAttributeGrid.CurrentAttributeToCheckModification);
                        //bool bIsContains = itemNewAttributeGrid.CurrentAttribute.Contains(itemNewAttributeGrid.CurrentAttributeToCheckModification);
                        if (bIsmodified)
                        {
                            string sNewAttributeValue = string.Empty;
                            if (!string.IsNullOrEmpty(itemNewAttributeGrid.CurrentAttributeToCheckModification))
                            {
                                sNewAttributeValue = itemNewAttributeGrid.CurrentAttribute.Replace(itemNewAttributeGrid.CurrentAttributeToCheckModification, string.Empty);
                            }
                            else
                            {
                                sNewAttributeValue = itemNewAttributeGrid.CurrentAttribute;
                            }


                            string[] sNewAttributes = sNewAttributeValue.Split(',');
                            int      iSubAttributeValueAttributeId = itemNewAttributeGrid.ParentOfSubAttribute.AttributeId;
                            foreach (string newAttribute in sNewAttributes)
                            {
                                AttributeValueModel objAttributeValueModel = new AttributeValueModel();
                                objAttributeValueModel.Name        = newAttribute;
                                objAttributeValueModel.ParentValue = itemNewAttributeGrid.ParentAttributeValueId;
                                objAttributeValueModel.AttributeId = iSubAttributeValueAttributeId;
                                lAttributeValueModel.Add(objAttributeValueModel);
                            }

                            // 1. Saving Attribute Value Model
                            bool isResult = objDataAccess.AddAttributeValueList(lAttributeValueModel);
                            if (isResult)
                            {
                                MessageBox.Show("Attribute Values inserted successfully");
                            }
                            else
                            {
                                MessageBox.Show("Attribute Values insertion failed");
                            }
                        }
                    }

                    /* If the Row is not modified then add it to Stagnate List */
                    /* If the Row is modified then respond accordingly */
                }
            }

            else if (iAttributeTypeSelectedValue == 1)
            {
                string sAttributeValue = txtParentAttribute.Text;
                objDataAccess.AddAttributeValueForPlainText(sAttributeValue, iAttributeId);
            }
        }
Esempio n. 14
0
        public async Task <IActionResult> CreateOrUpdate([FromBody] AttributeValueModel AttributeValue)
        {
            var result = await _attributeValueService.CreateOrUpdate(AttributeValue);

            return(Ok(result));
        }
Esempio n. 15
0
 public static AttributeValue ToAttributeValue(this AttributeValueModel model)
 {
     return(model.MapTo <AttributeValueModel, AttributeValue>());
 }