コード例 #1
0
        public async Task <string> AddUpdateSubCategory(SubCategoryDomainModel subCategory)
        {
            string status = "";

            if (subCategory.subCat_id > 0)
            {
                tblSubCategory subCategoryToUpdate = await subCategoryRepository.SingleOrDefault(s => s.subCat_id == subCategory.subCat_id);

                if (subCategoryToUpdate != null)
                {
                    subCategoryToUpdate.subCat_id = subCategory.subCat_id;
                    subCategoryToUpdate.name      = subCategory.name;
                    subCategoryToUpdate.cat_id    = subCategory.cat_id;

                    await subCategoryRepository.Update(subCategoryToUpdate);

                    status = "updated";
                }
            }
            else
            {
                tblSubCategory subCategoryToAdd = new tblSubCategory();
                subCategoryToAdd.subCat_id = subCategory.subCat_id;
                subCategoryToAdd.name      = subCategory.name;
                subCategoryToAdd.cat_id    = subCategory.cat_id;

                await subCategoryRepository.Insert(subCategoryToAdd);

                status = "added";
            }
            return(status);
        }
コード例 #2
0
        public async Task <string> AddUpdateUser(SubCategoryVM subCategoryVM)
        {
            SubCategoryDomainModel subCategoryDM = new SubCategoryDomainModel();

            AutoMapper.Mapper.Map(subCategoryVM, subCategoryDM);
            return(await subCategoryBusiness.AddUpdateSubCategory(subCategoryDM));
        }
コード例 #3
0
        public async Task <SubCategoryToReturnVM> GetSubCategoryById(int id)
        {
            SubCategoryToReturnVM  subCategoryToReturnVM  = new SubCategoryToReturnVM();
            SubCategoryDomainModel subCategoryDomainModel = await subCategoryBusiness.GetSubCategoryById(id);

            AutoMapper.Mapper.Map(subCategoryDomainModel, subCategoryToReturnVM);
            return(subCategoryToReturnVM);
        }
コード例 #4
0
        public async Task <SubCategoryDomainModel> GetSubCategoryById(int id)
        {
            SubCategoryDomainModel subCategory = new SubCategoryDomainModel();
            var model = await subCategoryRepository.SingleOrDefault(s => s.subCat_id == id);

            if (model != null)
            {
                subCategory           = new SubCategoryDomainModel();
                subCategory.subCat_id = model.subCat_id;
                subCategory.name      = model.name;
                subCategory.cat_id    = model.cat_id;
            }
            return(subCategory);
        }