Beispiel #1
0
        internal object RentalMark(RentalMark rentalMark)
        {
            //New
            if (rentalMark.FKCategory_Id <= 0 && rentalMark.FKSubCategory_Id <= 0)
            {
                return new { RequestType = RequestTypeEnumVM.Error, Message = Token.FiledIsRequired + " : " + Token.Category + " " + Token.Or + " " + Token.SubCategory }
            }
            ;

            //التحقق من عندم تكرار الفئنة الفعرية والفشة الرئيسية
            if (rentalMark.FKSubCategory_Id > 0)
            {
                if (db.RentalMarks.Any(x => x.FKMark_Id == rentalMark.FKMark_Id && x.FKSubCategory_Id == rentalMark.FKSubCategory_Id))
                {
                    var Dupl = db.RentalMarks.Where(c => c.FKSubCategory_Id == rentalMark.FKSubCategory_Id && c.FKMark_Id == rentalMark.FKMark_Id).Single();
                    return(new { RequestType = RequestTypeEnumVM.Error, Message = Token.CanNotDuplicateRow + " : " + Dupl.SubCategory.SubCategoryName + " " + Token.With + " : " + Dupl.Mark.MarkName });
                }
                //لم تملىء الا من هنا
                rentalMark.FKCategory_Id = db.SubCategories.Find(rentalMark.FKSubCategory_Id).FKCategory_Id;
            }
            else
            {
                if (db.RentalMarks.Any(x => x.FKMark_Id == rentalMark.FKMark_Id && x.FKCategory_Id == rentalMark.FKCategory_Id && !x.FKSubCategory_Id.HasValue))
                {
                    var Dupl = db.RentalIndividualFields.Where(c => c.FKCategory_Id == rentalMark.FKCategory_Id && c.FkIndividualField_Id == rentalMark.FKMark_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(rentalMark.FKCategory_Id);
            var Mark     = db.Marks.Find(rentalMark.FKMark_Id);

            db.RentalMarks.Add(rentalMark);
            return(null);
        }
        internal object RentalMark(RentalMark rentalMark)
        {

            var RentaMarkEdit = db.RentalMarks.Where(x => x.Id == rentalMark.Id).Single();
            var Category = RentaMarkEdit.Category;

            return null;
        }
Beispiel #3
0
        internal object RentalMark(RentalMark rentalMark)
        {
            var RentalMarkRemove = db.RentalMarks.Where(x => x.Id == rentalMark.Id).Single();

            if (RentalMarkRemove == null)
            {
                return(new ResponseVM(RequestTypeEnumVM.Error, RentalMarkRemove.Mark + " " + Token.NotFound));
            }


            //Delete
            db.RentalMarks.Remove(RentalMarkRemove);
            return(null);
        }