public IEnumerable <RigOapChecklist> GetProtocolsByAuditId(int auditId)
 {
     return((from it in AllItems.Include(a => a.RigOapChecklist)
             .Include(a => a.RigOapChecklist.OapChecklist.OapType).Where(a => a.RigOapChecklist.OapChecklist.OapType.Code != "AR")
             where it.AuditId == auditId
             select it.RigOapChecklist).ToList());
 }
Esempio n. 2
0
        public async Task <SubCategoryAndCategoryModel> ExistSubCategory(SubCategoryAndCategoryModel model, ICategoryRepository iCategoryRepository)
        {
            var exist = await AllItems.Include(z => z.Category).Where(x => x.NameSubCategory == model.SubCategoryModel.Name && x.Category.Id == Int32.Parse(model.SubCategoryModel.CategoryId)).ToListAsync();

            if (exist.Count > 0)
            {
                model.StatusMessage             = "Error: Sub category exist under" + model.SubCategoryModel.Name + "category. Please use another name.";
                model.SubCategoryModel.Category =
                    await iCategoryRepository.AllItems.FirstOrDefaultAsync(z =>
                                                                           z.Id == Int32.Parse(model.SubCategoryModel.CategoryId));

                model.Categories = await iCategoryRepository.GetAllCategory();

                return(model);
            }

            return(null);
        }
Esempio n. 3
0
        public async Task <SubCategoryModel> DeleteSubCategoryGet(int?id)
        {
            if (id == null)
            {
                return(null);
            }

            var subCategory = await AllItems.Include(z => z.Category).FirstOrDefaultAsync(x => x.Id == id);

            if (subCategory == null)
            {
                return(null);
            }
            SubCategoryModel model = new SubCategoryModel {
                Id = subCategory.Id, Name = subCategory.NameSubCategory, Category = subCategory.Category
            };

            return(model);
        }
Esempio n. 4
0
        public async Task <SubCategoryAndCategoryModel> EditGetSubCategory(int?id, ICategoryRepository iCategoryRepository)
        {
            if (id == null)
            {
                return(null);
            }
            var subCategory = await AllItems.Include(z => z.Category).FirstOrDefaultAsync(x => x.Id == id);

            if (subCategory == null)
            {
                return(null);
            }
            SubCategoryModel sub = new SubCategoryModel {
                Id = subCategory.Id, Name = subCategory.NameSubCategory, Category = subCategory.Category
            };
            SubCategoryAndCategoryModel model = new SubCategoryAndCategoryModel
            {
                Categories       = await iCategoryRepository.GetAllCategory(),
                SubCategoryModel = sub
            };

            return(model);
        }
Esempio n. 5
0
 public async Task <List <SubCategory> > GetListSubCategory()
 {
     return(await AllItems.Include(z => z.Category).ToListAsync());
 }