示例#1
0
        public ActionResult GetKitchenCategories()
        {
            ProductService serv = WebServiceUtils.GetEndpointService <ProductService>(ProductServiceInfo.ENDPOINT_NAME);
            RoomsCategory  room = new RoomsCategory();

            room.Name = "kitchen";
            RoomsCategory cats = serv.CategoriesForRoomsCategory(room);

            ViewBag.cats = cats;
            return(View());
        }
示例#2
0
 private RoomsCategory RoomCategoryForName(String name)
 {
     using (SqlConnection connection = this.getConnection()) {
         RoomsCategory     cat = null;
         DynamicParameters dp  = new DynamicParameters();
         dp.Add("@name", name);
         List <RoomsCategory> list = connection.Query <RoomsCategory>("RoomsCategory_ReadByName", dp, commandType: CommandType.StoredProcedure).ToList();
         if (list.Count > 0)
         {
             cat = list.First();
         }
         return(cat);
     }
 }
示例#3
0
        public RoomsCategory CategoriesForRoomsCategory(RoomsCategory roomcat)
        {
            if (roomcat == null)
            {
                return(roomcat);
            }
            List <ProductCategory> cats = null;

            using (SqlConnection connection = this.getProductConnection()) {
                //
                DynamicParameters dp = new DynamicParameters();
                dp.Add("@spacetype", roomcat.SpaceType);
                cats = connection.Query <ProductCategory>(@"select 
                    *
                from 
                    ProductCatalog.Category
                where
                    ProductCatalog.Category.SpaceType = @spacetype", dp).ToList();
            }
            // Hack the product images! Get this in a better way when we have them
            using (SqlConnection connection = this.getConnection())
            {
                DynamicParameters dp   = null;
                List <TempImage>  imgs = null;
                foreach (ProductCategory cat in cats)
                {
                    dp = new DynamicParameters();
                    dp.Add("@catguid", cat.CategoryGuid);
                    imgs = connection.Query <TempImage>("select * from ProductCategoryImages where CategoryGuid = @catguid", dp).ToList();
                    if (imgs.Count > 0)
                    {
                        cat.Image = imgs.First().ImageUrl;
                    }
                }
            }
            roomcat.ProductCategories = cats;
            //
            return(roomcat);
        }
示例#4
0
        //  There are four possible room types.  This iterates through the room types, figures out
        //  how many are on the project, and creates the room instances where need be.
        //  This could be done more elegantly, but I didn't figure that out in my timebox, so quick and
        //  dirty it is - BMW.
        private void CreateRooms(int customerId, int newProjectId, SqlConnection connection, CreateProjectFromUI project)
        {
            RoomsCategory rc = new RoomsCategory();

            rc.Name = "laundry";
            for (var i = 0; i < project.laundry; i++)
            {
                var p = new DynamicParameters();
                p.Add("@FKRoomsCategory", rc.SpaceType);
                p.Add("@FKProject", newProjectId);
                connection.Execute("Room_Create", p, commandType: CommandType.StoredProcedure);
            }
            rc.Name = "bathroom";
            for (var i = 0; i < project.bathrooms; i++)
            {
                var p = new DynamicParameters();
                p.Add("@FKRoomsCategory", rc.SpaceType);
                p.Add("@FKProject", newProjectId);
                connection.Execute("Room_Create", p, commandType: CommandType.StoredProcedure);
            }
            rc.Name = "kitchen";
            for (var i = 0; i < project.kitchens; i++)
            {
                var p = new DynamicParameters();
                p.Add("@FKRoomsCategory", rc.SpaceType);
                p.Add("@FKProject", newProjectId);
                connection.Execute("Room_Create", p, commandType: CommandType.StoredProcedure);
            }
            rc.Name = "outdoor";
            for (var i = 0; i < project.outdoor; i++)
            {
                var p = new DynamicParameters();
                p.Add("@FKRoomsCategory", rc.SpaceType);
                p.Add("@FKProject", newProjectId);
                connection.Execute("Room_Create", p, commandType: CommandType.StoredProcedure);
            }
        }
示例#5
0
        public RoomsCategory CategoriesForRoomsCategory(String name)
        {
            RoomsCategory cat = this.RoomCategoryForName(name);

            return(this.CategoriesForRoomsCategory(cat));
        }