Exemplo n.º 1
0
        public bool AddSize(string sizeName, int width, int height, int thumb_width, int thumb_height, int cover_width, int cover_height, out IList<string> errors)
        {
            using (var context = new WSI.DataAccess.WSICmsContext())
            {
                var entity = new ImageSize()
                {
                    SizeName = sizeName,
                    Width = width,
                    Height = height,
                    ThumbWidth = thumb_width,
                    ThumbHeight = thumb_height,
                    CoverWidth = cover_width,
                    CoverHeight = cover_height,
                    State = (int)EnumHelper.State.Enable,
                    CreateTime = DateTime.Now
                };

                var validate = context.Entry(entity).GetValidationResult();
                if (!validate.IsValid)
                {
                    errors = validate.ValidationErrors.Select(e => e.ErrorMessage).ToList();
                    return false;
                }
                context.ImageSizes.Add(entity);

                context.LogChangesDuringSave = true;
                context.SaveChanges();

                errors = null;
                return true;
            }
        }
Exemplo n.º 2
0
        public int ChangeState(ImageSize item, int state)
        {
            using (var context = new WSI.DataAccess.WSICmsContext())
            {
                context.ImageSizes.Attach(item);
                item.State = state;

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