Exemplo n.º 1
0
        public Result Insert(PostCardEntity entity)
        {
            ImageManager imageManager = new ImageManager();

            if (entity.ImageFile != null)
            {
                var resImgCheck = imageManager.CheckFileImageAndSave(entity.ImagePath, entity.ImageFile, 100, 100, 3000, 3000);
                if (!resImgCheck.Success)
                {
                    return(resImgCheck);
                }
                entity.Image = resImgCheck.Entity.ToString();
                //entity.Text = "Image Postcard";
            }

            var con   = new DapperConnectionManager();
            var query = new QueryEntity();

            query.Entity = entity;
            query.Query  = @"INSERT INTO PostCards (Text, Image) VALUES(@Text, @Image)";
            var result = con.InsertQuery(query);

            result.Message = result.Success ? "The PostCard has been created" : "An error occurred";
            return(result);
        }
Exemplo n.º 2
0
        public Result Update(PostCardEntity entity)
        {
            ImageManager imageManager = new ImageManager();

            if (entity.ImageFile != null)
            {
                var resImgCheck = imageManager.CheckFileImageAndSave(entity.ImagePath, entity.ImageFile, 30, 30, 3000, 3000);
                if (!resImgCheck.Success)
                {
                    return(resImgCheck);
                }
                entity.Image = resImgCheck.Entity.ToString();
                //entity.Text = "Image Postcard";
            }

            var con   = new DapperConnectionManager();
            var query = new QueryEntity();

            query.Entity = entity;
            query.Query  = @"UPDATE PostCards set Text = @Text, Image = @Image where PostCardId = @PostCardId";
            var result = con.ExecuteQuery(query);

            result.Message = result.Success ? "The PostCard has been updated" : "An error occurred";
            result.Entity  = entity.PostCardId;
            return(result);
        }