internal object SubCategory(SubCategory rentalSubCategory) { var SubCategoryRemove = db.SubCategories.Find(rentalSubCategory.Id); if ( SubCategoryRemove.RentalIndividualFields.Count > 0 || SubCategoryRemove.RentalMarks.Count > 0 || SubCategoryRemove.RentalMaterials.Count > 0 || SubCategoryRemove.GroupsDisplayTypes.Count > 0 || SubCategoryRemove.RentalGroupsItems.Count > 0 || SubCategoryRemove.RentalMaterials.Count > 0) { return(new ResponseVM(RequestTypeEnumVM.Error, Token.CanNotDelete + " >> " + SubCategoryRemove.SubCategoryName)); } FilesRemove.Add(SubCategoryRemove.AllFile.FileUrl); //Delete db.SubCategories.Remove(SubCategoryRemove); return(null); }
internal object Category(Category item) { var CategoryRemove = db.Categories.Find(item.Id); if (CategoryRemove.SubCategories.Count > 0 || CategoryRemove.GroupsDisplayTypes.Count > 0 || CategoryRemove.RentalGroupsItems.Count > 0 || CategoryRemove.RentalMaterials.Count > 0) { this.FilesRemove = new List <string>(); return(new ResponseVM(RequestTypeEnumVM.Error, Token.CanNotDelete + " >> " + CategoryRemove.CategoryName)); } FilesRemove.Add(CategoryRemove.AllFile.FileUrl); //Delete db.Categories.Remove(CategoryRemove); return(null); }
internal object SubCategory(SubCategory rentalSubCategory) { if (db.SubCategories.Where(x => x.Id != rentalSubCategory.Id).Any(x => x.NameAr == rentalSubCategory.NameAr)) return new ResponseVM(RequestTypeEnumVM.Warning, Token.CanNotDuplicateRow + " >> " + rentalSubCategory.NameAr); if (db.SubCategories.Where(x => x.Id != rentalSubCategory.Id).Any(x => x.NameEn == rentalSubCategory.NameEn)) return new ResponseVM(RequestTypeEnumVM.Warning, Token.CanNotDuplicateRow + " >> " + rentalSubCategory.NameEn); var SubCategoryEdit = db.SubCategories.Find(rentalSubCategory.Id); //Upload New Image if (!string.IsNullOrEmpty(rentalSubCategory.Image64)) { FileSaveVM ImageUpdate = FileService.SaveFileBase64(new FileSaveVM() { FileBase64 = rentalSubCategory.Image64, }); if (!ImageUpdate.IsSave) return new ResponseVM(RequestTypeEnumVM.Error, Token.CanNotSaveImage); FilesRemove.Add(SubCategoryEdit.AllFile.FileUrl); //Add New Image Url SubCategoryEdit.AllFile.FileUrl = ImageUpdate.SavedPath; } //Update Now SubCategoryEdit.NameAr = rentalSubCategory.NameAr; SubCategoryEdit.NameEn = rentalSubCategory.NameEn; return null; }