Exemple #1
0
        public NinjaBarbie2016SharingViewModel SaveSurprize(NinjaBarbie2016SurprizeViewModel model)
        {
            byte[]       byteArray = Convert.FromBase64String(model.FacebookImage);
            MemoryStream stream    = new MemoryStream(byteArray);

            model.FacebookImage = common.S3FileUpload(stream, "NinjaBarbie2016", "synthesisImage.jpg");

            byteArray            = Convert.FromBase64String(model.KakaotalkImage);
            stream               = new MemoryStream(byteArray);
            model.KakaotalkImage = common.S3FileUpload(stream, "NinjaBarbie2016", "synthesisImage.jpg");

            byteArray             = Convert.FromBase64String(model.KakaostoryImage);
            stream                = new MemoryStream(byteArray);
            model.KakaostoryImage = common.S3FileUpload(stream, "NinjaBarbie2016", "synthesisImage.jpg");

            var user = service.GetUsers().Where(x => x.Id == model.UserId).SingleOrDefault();

            if (user == null)
            {
            }
            var mapper = mapperConfig.CreateMapper();
            var entry  = mapper.Map <NinjaBarbie2016SurprizeViewModel, NinjaBarbie2016User>(model, user);
            var update = service.UpdateUser(entry);

            return(new NinjaBarbie2016SharingViewModel {
                UserId = update.Id,
                FacebookImage = update.FacebookImage,
                KakaotalkImage = update.KakaotalkImage,
                KakaostoryImage = update.KakaostoryImage
            });
        }
Exemple #2
0
        public ActionResult Post(BagtotheFutureModel model)
        {
            if (ModelState.IsValid)
            {
                var entry = mapperConfig.CreateMapper().Map <BagtotheFutureEntryModel>(model.BagtotheFutureEntryCheckModel);
                if (model.BagtotheFutureEntryCheckModel.Attachment != null)
                {
                    var fileName = string.Format("{0}-{1}{2}", DateTime.Now.ToString("yyMMddHHmmss"), Guid.NewGuid(), Path.GetExtension(model.BagtotheFutureEntryCheckModel.Attachment.FileName));
                    entry.File = common.S3FileUpload(model.BagtotheFutureEntryCheckModel.Attachment.InputStream,
                                                     "files/bag-to-the-future", fileName);
                }
                return(Json(entry, "text/html"));
            }
            else
            {
                string message = "";

                var errorProp = ModelState.Values.Where(x => x.Errors.Count > 0).FirstOrDefault();
                if (errorProp != null)
                {
                    message = errorProp.Errors[0].ErrorMessage;
                }
                return(Json(new {
                    result = false,
                    message = message
                }, "text /html"));
            }
        }
Exemple #3
0
        public Domain.Entities.Christmas2015.Christmas2015MakeTree MakeTree(Christmas2015MakeTreeModel entry)
        {
            byte[]       byteArray = Convert.FromBase64String(entry.SynthesisImage);
            MemoryStream stream    = new MemoryStream(byteArray);
            string       saveImage = common.S3FileUpload(stream, "Christmas2015", "synthesisImage.jpg");

            var result = repository.UpdateChristmas2015MakeTreeById(new Domain.Entities.Christmas2015.Christmas2015MakeTree {
                Id             = entry.MakeTreeId,
                Toy1           = entry.Toy1,
                Toy2           = entry.Toy2,
                Toy3           = entry.Toy3,
                Toy4           = entry.Toy4,
                Toy5           = entry.Toy5,
                Toy6           = entry.Toy6,
                Toy7           = entry.Toy7,
                SynthesisImage = saveImage,
                Content        = entry.Content
            });

            return(result);
        }
Exemple #4
0
        public ActionResult CreateMagicKinderAppLaunching(MagicKinderAppLaunchingEventModel model)
        {
            try
            {
                //if (common.Now >= new DateTime(2017, 4, 15))
                //{
                //    throw new Exception("이벤트가 종료되었습니다.");
                //}
                if (!ModelState.IsValid)
                {
                    var errorProp = ModelState.Values.Where(x => x.Errors.Count > 0).FirstOrDefault();
                    if (errorProp != null)
                    {
                        throw new Exception(errorProp.Errors[0].ErrorMessage);
                    }
                }

                var mapper = mapperConfig.CreateMapper();
                var entry  = mapper.Map <MagicKinderAppLaunching>(model);

                entry.IpAddress  = common.ClientIP;
                entry.Channel    = common.IsMobileDevice ? "mobile" : "pc";
                entry.CreateDate = common.Now;
                entry.IsShow     = false;

                var img = Image.FromStream(model.ScreenShotFile.InputStream);
                //이미지 회전 check
                if (img.PropertyIdList.Contains(0x0112))
                {
                    int rotationValue = img.GetPropertyItem(0x0112).Value[0];
                    switch (rotationValue)
                    {
                    case 1:
                        // No rotation required.
                        break;

                    case 2:
                        img.RotateFlip(RotateFlipType.RotateNoneFlipX);
                        break;

                    case 3:
                        img.RotateFlip(RotateFlipType.Rotate180FlipNone);
                        break;

                    case 4:
                        img.RotateFlip(RotateFlipType.Rotate180FlipX);
                        break;

                    case 5:
                        img.RotateFlip(RotateFlipType.Rotate90FlipX);
                        break;

                    case 6:
                        img.RotateFlip(RotateFlipType.Rotate90FlipNone);
                        break;

                    case 7:
                        img.RotateFlip(RotateFlipType.Rotate270FlipX);
                        break;

                    case 8:
                        img.RotateFlip(RotateFlipType.Rotate270FlipNone);
                        break;
                    }
                    // This EXIF data is now invalid and should be removed.
                    img.RemovePropertyItem(0x0112);
                }

                using (MemoryStream ms = new MemoryStream())
                {
                    //회전시킨 이미지를 스트림에 저장
                    img.Save(ms, ImageFormat.Jpeg);

                    //회전시킨 원본이미지 s3에 upload
                    entry.ScreenShot = common.S3FileUpload(ms, "MagicKinderAppLaunching2017", model.ScreenShotFile.FileName.ToString());
                }
                var result = service.CreateMagicKinderAppLaunching(entry);

                return(Json(new
                {
                    result = true,
                    data = result
                }));
            }
            catch (Exception e)
            {
                return(Json(new
                {
                    result = false,
                    message = e.Message
                }));
            }
        }