internal object RentalMaterial(RentalMaterial rentalMaterial) { //New if (rentalMaterial.FKCategory_Id <= 0 && rentalMaterial.FKSubCategory_Id <= 0) { return new { RequestType = RequestTypeEnumVM.Error, Message = Token.FiledIsRequired + " : " + Token.Category + " " + Token.Or + " " + Token.SubCategory } } ; //التحقق من عندم تكرار الفئنة الفعرية والفشة الرئيسية if (rentalMaterial.FKSubCategory_Id > 0) { if (db.RentalMaterials.Any(x => x.FKMaterial_Id == rentalMaterial.FKMaterial_Id && x.FKSubCategory_Id == rentalMaterial.FKSubCategory_Id)) { var Dupl = db.RentalMaterials.Where(c => c.FKSubCategory_Id == rentalMaterial.FKSubCategory_Id && c.FKMaterial_Id == rentalMaterial.FKMaterial_Id).Single(); return(new { RequestType = RequestTypeEnumVM.Error, Message = Token.CanNotDuplicateRow + " : " + Dupl.SubCategory.SubCategoryName + " " + Token.With + " : " + Dupl.Material.MaterialName }); } //لم تملىء الا من هنا rentalMaterial.FKCategory_Id = db.SubCategories.Find(rentalMaterial.FKSubCategory_Id).FKCategory_Id; } else { if (db.RentalMaterials.Any(x => x.FKMaterial_Id == rentalMaterial.FKMaterial_Id && x.FKCategory_Id == rentalMaterial.FKCategory_Id && !x.FKSubCategory_Id.HasValue)) { var Dupl = db.RentalIndividualFields.Where(c => c.FKCategory_Id == rentalMaterial.FKCategory_Id && c.FkIndividualField_Id == rentalMaterial.FKMaterial_Id).Single(); return(new { RequestType = RequestTypeEnumVM.Error, Message = Token.CanNotDuplicateRow + " : " + Dupl.Category.CategoryName + " " + Token.With + " : " + Dupl.IndividualField.InputName, Title = Token.Warning }); } } var Category = db.Categories.Find(rentalMaterial.FKCategory_Id); var Material = db.Materials.Find(rentalMaterial.FKMaterial_Id); db.RentalMaterials.Add(rentalMaterial); return(null); }
internal object RentalMaterial(RentalMaterial rentalMaterial) { var RentaMaterialEdit = db.RentalMaterials.Where(x => x.Id == rentalMaterial.Id).Single(); var Category = RentaMaterialEdit.Category; return null; }
internal object RentalMaterial(RentalMaterial rentalMaterial) { var RentalMaterialRemove = db.RentalMaterials.Where(x => x.Id == rentalMaterial.Id).Single(); if (RentalMaterialRemove == null) { return(new ResponseVM(RequestTypeEnumVM.Error, RentalMaterialRemove.Material + " " + Token.NotFound)); } //Delete db.RentalMaterials.Remove(RentalMaterialRemove); return(null); }