public DataAccessSearch.ItemImage GetApprovedImageUrl()
        {
            context = new AddisTowerDataContext();
            DataAccessSearch.Motorcycle motorcycle = GetApprovedMotor();
            var selectedMotor = from p in context.ItemImages
                                where p.MotorOrSpareId == motorcycle.Id
                                select p;

            return(selectedMotor.First());
        }
        public void UnApproveSelected()
        {
            var selectedApproved = from p in context.Motorcycles
                                   where p.Approve == true
                                   select p;

            if (!selectedApproved.Equals(null))
            {
                DataAccessSearch.Motorcycle motorcycle = selectedApproved.First();
                motorcycle.Approve = false;
                context.SubmitChanges();
            }
        }
        public void UpdateMotorcycle(Guid Id, string Number, string Name, string Model, bool Approve, string Description, double Quantity)
        {
            context = new AddisTowerDataContext();
            if (Approve)
            {
                UnApproveSelected();
            }
            var selectedSparepart = from p in context.Motorcycles
                                    where p.Id == Id
                                    select p;

            DataAccessSearch.Motorcycle motorcycle = selectedSparepart.First();
            motorcycle.Number      = Number;
            motorcycle.Name        = Name;
            motorcycle.Model       = Model;
            motorcycle.Approve     = Approve;
            motorcycle.Description = Description;
            motorcycle.Quantity    = Quantity;

            context.SubmitChanges();
        }
        public void InsertNewMotorcycle(Guid CategoryId, string Number, string Name, string Model, bool Approve, string Description, double Quantity)
        {
            context = new AddisTowerDataContext();
            if (Approve)
            {
                UnApproveSelected();
            }
            var motorCycleEntity = new DataAccessSearch.Motorcycle
            {
                Approve     = Approve,
                CategoryId  = CategoryId,
                Description = Description,
                Id          = Guid.NewGuid(),
                Model       = Model,
                Name        = Name,
                Number      = Number,
                Quantity    = Quantity
            };

            context.Motorcycles.InsertOnSubmit(motorCycleEntity);
            context.SubmitChanges();
        }