Exemple #1
0
        public CustomerList GetCustomerDetailByID(int customerId)
        {
            RentalService rentalService = new RentalService();

            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Users
                    .Single(e => e.UserID == customerId);
                return
                    (new CustomerList
                {
                    UserID = entity.UserID,
                    FName = entity.FName,
                    LName = entity.LName,
                    StreetAddress = entity.StreetAddress,
                    City = entity.City,
                    State = entity.State,
                    Zip = entity.Zip,
                    Rentals = rentalService.GetRentalByCustomerID(customerId),
                    EaseRating = entity.EaseRating,
                    CareRating = entity.CareRating,
                    TimelinessAsCustomerRating = entity.TimelinessAsCustomerRating
                });
            }
        }
        public bool DeleteTool(int toolId)
        {
            var rentalservice = new RentalService();

            // null add th etoolID's for any rentals with this tool ID

            rentalservice.NullToolIDForRentalByToolID(toolId);

            // now remove those tool rows

            using (var ctx = new ApplicationDbContext())
            {
                var entity = ctx.Tools.Single(e => e.ToolID == toolId);

                ctx.Tools.Remove(entity);

                return(ctx.SaveChanges() == 1);
            }
        }