Beispiel #1
0
        public ActionResult UploadAngularFileOnImgUr(HttpPostedFileBase file)
        {            
            bool isDummy = false; 
            

            if (isDummy)
            {
                var dummyImgurImage = new ImgurImageResponse();
                dummyImgurImage.data = new imgurData();
                dummyImgurImage.data.link_s = "http://i.imgur.com/FdU2YRFs.jpg";
                dummyImgurImage.data.link = "http://i.imgur.com/FdU2YRF.jpg";
                return Json(dummyImgurImage);
            }

            const string albumid = "Xlh72LgTBw6Tzs1";
            var imgurService = new imgurService();
            var uploadedImagesId = imgurService.UploadSingleImageToImgur(file, albumid);

            return Json(uploadedImagesId);
        }
Beispiel #2
0
        public ResponseModel<List<ImgurImageResponse>> GetTemplateImageDetailById(string username, long id)
        {
            var response = new ResponseModel<List<ImgurImageResponse>>();
            try
            {
                var refKey = username + id;
                var createTemplateImagesListsCreateResponse = _db.CreateTemplateImgurImagesLists.OrderBy(x => x.Id).Where(x => x.referenceKey == refKey && x.username == username).ToList();

                if (createTemplateImagesListsCreateResponse != null)
                {
                    var imgurImageList = new List<ImgurImageResponse>();
                    foreach (var createTemplateImageCreateResponse in createTemplateImagesListsCreateResponse)
                    {
                        var imgurImage = new ImgurImageResponse();
                        imgurImage.data = new imgurData();
                        imgurImage.data.id = createTemplateImageCreateResponse.Id.ToString();
                        imgurImage.data.deletehash = createTemplateImageCreateResponse.imgurDeleteHash;
                        imgurImage.data.link = createTemplateImageCreateResponse.imgurLink;
                        imgurImage.data.link_s = createTemplateImageCreateResponse.imgurLink.Split('/')[0] + "//" + createTemplateImageCreateResponse.imgurLink.Split('/')[2] + "/" + createTemplateImageCreateResponse.imgurLink.Split('/')[3].Split('.')[0] + 's' + "." + createTemplateImageCreateResponse.imgurLink.Split('/')[3].Split('.')[1];
                        imgurImage.data.link_m = createTemplateImageCreateResponse.imgurLink.Split('/')[0] + "//" + createTemplateImageCreateResponse.imgurLink.Split('/')[2] + "/" + createTemplateImageCreateResponse.imgurLink.Split('/')[3].Split('.')[0] + 'm' + "." + createTemplateImageCreateResponse.imgurLink.Split('/')[3].Split('.')[1];
                        imgurImage.data.link_l = createTemplateImageCreateResponse.imgurLink.Split('/')[0] + "//" + createTemplateImageCreateResponse.imgurLink.Split('/')[2] + "/" + createTemplateImageCreateResponse.imgurLink.Split('/')[3].Split('.')[0] + 'l' + "." + createTemplateImageCreateResponse.imgurLink.Split('/')[3].Split('.')[1];
                        imgurImage.data.copyText ="";
                        imgurImageList.Add(imgurImage);
                    }
                    response.Status = 200;
                    response.Message = "success";
                    response.Payload = imgurImageList;
                }
                else
                {
                    response.Status = 404;
                    response.Message = "No Data found";
                }
                return response;
            }
            catch (Exception ex)
            {
                response.Status = 500;
                response.Message = "Exception";
                return response;
            }
        }