コード例 #1
0
        /// <summary>
        /// Edits the specified it.
        /// </summary>
        /// <param name="catalogObject">catalog Object.</param>
        /// <returns>the Edit</returns>
        public int Edit(Catalog catalogObject, CatalogDetail catalogDetail)
        {
            using (var data = new themanorContext())
            {
                int rt = 0;
                try
                {
                    var c_gen       = data.Catalog.Where(p => p.CatalogId == catalogObject.CatalogId).FirstOrDefault();
                    var c_genDetail = data.CatalogDetail.Where(x => x.CatalogId == catalogObject.CatalogId && x.Lang == catalogDetail.Lang).FirstOrDefault();
                    c_gen.ParentId           = catalogObject.ParentId;
                    c_genDetail.CategoryName = catalogDetail.CategoryName;
                    c_gen.ImagePath          = catalogObject.ImagePath;
                    c_genDetail.Link         = catalogDetail.Link;
                    c_genDetail.Intro        = catalogDetail.Intro;
                    c_genDetail.MoreInfo     = catalogDetail.MoreInfo;
                    c_genDetail.Keyword      = catalogDetail.Keyword;
                    c_genDetail.Description  = catalogDetail.Description;
                    c_genDetail.Title        = catalogDetail.Title;
                    c_gen.Type         = catalogObject.Type;
                    c_gen.OrderDisplay = catalogObject.OrderDisplay;
                    c_gen.Show         = catalogObject.Show;
                    c_genDetail.Lang   = catalogDetail.Lang;
                    c_gen.ModifyDate   = catalogObject.ModifyDate;
                    data.SaveChanges();
                    rt = catalogObject.CatalogId;
                }
                catch (Exception)
                {
                    rt = 0;
                }

                return(rt);
            }
        }
コード例 #2
0
        public IActionResult Detail(int id)
        {
            var movie = _movies.Get(id);


            CatalogDetail model = new CatalogDetail();

            ;


            model.Author   = movie.Author;
            model.Title    = movie.Title;
            model.Date     = movie.Date;
            model.Content  = movie.Content;
            model.ImageUrl = movie.ImageUrl;



            return(View(model));
        }
コード例 #3
0
        public CatalogDetail GetCatalogDetail(int id)
        {
            var model = _context.Catalogs.Find(id);

            if (model.catalogtypeid == 1)
            {
                var query = from c in _context.Catalogs
                            join t in _context.CatalogTypes on c.catalogtypeid equals t.id
                            join b in _context.CatalogBrands on c.catalogbrandid equals b.id
                            join sp in _context.Specifications on c.id equals sp.catalogid
                            join sm in _context.SpecificationsMobiles on c.id equals sm.catalogid
                            where c.id == id
                            select new { c, t, b, sp, sm };
                CatalogDetail catalog = new CatalogDetail();
                foreach (var item in query)
                {
                    catalog.id              = item.c.id;
                    catalog.name            = item.c.name;
                    catalog.pictureuri      = item.c.pictureuri;
                    catalog.price           = item.c.price;
                    catalog.description     = item.c.description;
                    catalog.content         = item.c.content;
                    catalog.quantity        = item.c.quantity;
                    catalog.catalogbrandid  = item.c.catalogbrandid;
                    catalog.catalogtypeid   = item.c.catalogtypeid;
                    catalog.catalogtypename = item.t.type;
                    catalog.cpu             = item.sp.cpu;
                    catalog.ram             = item.sp.ram;
                    catalog.screen          = item.sp.screen;
                    catalog.os              = item.sp.os;
                    catalog.backcamera      = item.sm.backcamera;
                    catalog.frontcamera     = item.sm.frontcamera;
                    catalog.internalmemory  = item.sm.internalmemory;
                    catalog.memorystick     = item.sm.memorystick;
                    catalog.sim             = item.sm.sim;
                    catalog.batery          = item.sm.batery;
                }
                return(catalog);
            }
            else
            {
                var query = from c in _context.Catalogs
                            join t in _context.CatalogTypes on c.catalogtypeid equals t.id
                            join b in _context.CatalogBrands on c.catalogbrandid equals b.id
                            join sp in _context.Specifications on c.id equals sp.catalogid
                            join sl in _context.SpecificationsLaptops on c.id equals sl.catalogid
                            where c.id == id
                            select new { c, t, b, sp, sl };
                CatalogDetail catalog = new CatalogDetail();
                foreach (var item in query)
                {
                    catalog.id              = item.c.id;
                    catalog.name            = item.c.name;
                    catalog.pictureuri      = item.c.pictureuri;
                    catalog.price           = item.c.price;
                    catalog.description     = item.c.description;
                    catalog.content         = item.c.content;
                    catalog.quantity        = item.c.quantity;
                    catalog.catalogbrandid  = item.c.catalogbrandid;
                    catalog.catalogtypeid   = item.c.catalogtypeid;
                    catalog.catalogtypename = item.t.type;
                    catalog.cpu             = item.sp.cpu;
                    catalog.ram             = item.sp.ram;
                    catalog.screen          = item.sp.screen;
                    catalog.os              = item.sp.os;
                    catalog.cardscreen      = item.sl.cardscreen;
                    catalog.connector       = item.sl.connector;
                    catalog.harddrive       = item.sl.harddrive;
                    catalog.design          = item.sl.design;
                    catalog.size            = item.sl.size;
                    catalog.release         = item.sl.release;
                }
                return(catalog);
            }
        }