Beispiel #1
0
        public async Task <ActionResult> GetAllAttrsByCat(int catid)
        {
            try
            {
                CatAttrRelationRepository carr = new CatAttrRelationRepository(new DAL.Context.BarayandContext(null));
                var catattrs = ((List <CatAttrRelationModel>)(await _repository.GetAll()).Data).Where(x => x.X_IsDeleted == false && x.X_Status && x.X_CatId == catid).ToList();
                List <AttributeModel> data = ((List <AttributeModel>)(await _attrs.GetAll()).Data);
                List <object>         Data = new List <object>();

                foreach (var item in catattrs)
                {
                    var attribute = data.FirstOrDefault(x => x.A_Id == item.X_AttrId);
                    if (attribute != null)
                    {
                        Data.Add(new
                        {
                            A_Title    = attribute.A_Title,
                            A_Id       = attribute.A_Id,
                            A_Status   = item.X_Status,
                            relationId = item.X_Id,
                        });
                    }
                }
                return(new JsonResult(ResponseModel.Success(data: Data)));
            }
            catch (Exception ex)
            {
                return(new JsonResult(ResponseModel.ServerInternalError(data: ex)));
            }
        }
 public async Task <ActionResult> GetAllAttrsByCat(int catid)
 {
     try
     {
         CatAttrRelationRepository carr = new CatAttrRelationRepository(new DAL.Context.BarayandContext(null));
         return(new JsonResult(await carr.GetAttrsByCat(catid)));
     }
     catch (Exception ex)
     {
         return(null);
     }
 }