예제 #1
0
        public static bool Delete(string id)
        {
            if (!General.IsNullable(id))
            {
                string fileName = null;

                using (WMContext context = new WMContext())
                {
                    GoodBrands model = context.GoodBrands.Find(id);

                    if (model != null)
                    {
                        if (!General.IsNullable(model.Logo))
                        {
                            fileName = "~" + model.Logo;
                        }

                        context.GoodBrands.Remove(model);
                        context.SaveChanges();
                    }
                }

                if (!General.IsNullable(fileName))
                {
                    return(Jumpcity.IO.FileHelper.DeleteFile(fileName));
                }

                return(true);
            }

            return(false);
        }
예제 #2
0
        public bool Update()
        {
            if (this.Valid(true))
            {
                using (WMContext context = new WMContext())
                {
                    GoodBrands model = context.GoodBrands.Find(this.Id);

                    if (model != null)
                    {
                        model.Name = this.Name;
                        model.Logo = this.Logo;
                        model.URL  = this.URL;

                        context.SaveChanges();
                        return(true);
                    }
                }
            }

            return(false);
        }
예제 #3
0
        public bool Add()
        {
            if (this.Valid())
            {
                this.Id = General.UniqueString(this.Id);

                using (WMContext context = new WMContext())
                {
                    GoodBrands model = new GoodBrands {
                        Id   = this.Id,
                        Name = this.Name,
                        Logo = this.Logo,
                        URL  = this.URL
                    };

                    context.GoodBrands.Add(model);
                    context.SaveChanges();
                }

                return(true);
            }

            return(false);
        }
예제 #4
0
        public bool Add()
        {
            if (this.Valid())
            {
                this.Id = General.UniqueString(this.Id);

                using (WMContext context = new WMContext())
                {
                    GoodBrands model = new GoodBrands {
                        Id = this.Id,
                        Name = this.Name,
                        Logo = this.Logo,
                        URL = this.URL
                    };

                    context.GoodBrands.Add(model);
                    context.SaveChanges();
                }

                return true;
            }

            return false;
        }