コード例 #1
0
         public ActionResult Index()
         {
             AmazonS3Uploader amazonS3 = new AmazonS3Uploader();
 
             amazonS3.UploadFile();
             return View();
         }
コード例 #2
0
        public objRegisterResponseModel UpdateUserProfile()
        {
            IAuthentication          _repository = new DataAccess.Authentication.Authentication();
            objRegisterResponseModel response    = new objRegisterResponseModel();
            AppResponseView          appResponse = new AppResponseView();
            ////////////////////////////////////////////
            var            httpRequest = HttpContext.Current.Request;
            HttpPostedFile postedFile  = null;

            if (httpRequest.Files.Count > 0)
            {
                postedFile = httpRequest.Files[0];
            }
            //convert the posted file stream a to memory stream
            //System.IO.MemoryStream target = new System.IO.MemoryStream();
            //postedFile.InputStream.CopyTo(target);
            //the following static function is a function I built which accepts the amazon file key and also the object that will be uploaded to S3, in this case, a MemoryStream object
            UserModel request = new UserModel();

            request.Id       = int.Parse(httpRequest.Form["UserId"]);
            request.FullName = httpRequest.Form["FullName"] == ""?null: httpRequest.Form["FullName"];
            request.PhoneNo  = httpRequest.Form["PhoneNo"] == "" ? null : httpRequest.Form["PhoneNo"];
            request.EmailId  = httpRequest.Form["EmailId"] == "" ? null : httpRequest.Form["EmailId"];
            request.Password = httpRequest.Form["Password"] == "" ? null : httpRequest.Form["Password"];
            if (postedFile != null)
            {
                AmazonS3Uploader service = new AmazonS3Uploader();
                request.ProfilePic = service.UploadFile("FarmPeProfilePics/" + request.Id + postedFile.FileName, new HttpPostedFileWrapper(postedFile));
            }

            //////////////////////////////////////////////
            appResponse.Status = _repository.UpdateUserProfile(request);
            response.Response  = appResponse;
            return(response);
        }
コード例 #3
0
ファイル: HomeController.cs プロジェクト: hunghop090/Engnest
 public ActionResult CreatedPost(PostModel model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             Post post = new Post();
             post = Mapper.Map <Post>(model);
             if (model.ListImages != null)
             {
                 foreach (var item in model.ListImages)
                 {
                     if (string.IsNullOrEmpty(post.Images))
                     {
                         //Task<string> task = Task.Run<string>(async () => await UploadImageTifiny.TinifyModulAsync(item,TypeUpload.IMAGE));
                         var result = AmazonS3Uploader.UploadFile(item, TypeUpload.IMAGE);
                         if (result == "")
                         {
                             continue;
                         }
                         post.Images += result;
                     }
                     else
                     {
                         //Task<string> task = Task.Run<string>(async () => await UploadImageTifiny.TinifyModulAsync(item,TypeUpload.IMAGE));
                         var result = AmazonS3Uploader.UploadFile(item, TypeUpload.IMAGE);
                         if (result == "")
                         {
                             continue;
                         }
                         post.Images += "," + result;
                     }
                 }
             }
             if (model.ListVideos != null)
             {
                 foreach (var item in model.ListVideos)
                 {
                     if (string.IsNullOrEmpty(post.Videos))
                     {
                         post.Videos += AmazonS3Uploader.UploadFile(item, TypeUpload.VIDEO);
                     }
                     else
                     {
                         post.Videos += "," + AmazonS3Uploader.UploadFile(item, TypeUpload.VIDEO);
                     }
                 }
             }
             postRepository.InsertPost(post);
         }
         catch (Exception ex)
         {
             return(Json(new { result = Constant.ERROR }));
         }
     }
     Response.StatusCode = (int)HttpStatusCode.OK;
     return(Json(new { result = Constant.SUCCESS }));
 }
コード例 #4
0
        public ResponseModel AddUpdateFarms()//FarmsModel request, HttpPostedFile farmimage, HttpPostedFile coverimage)
        {
            IAuthentication         _authrepository = new DataAccess.Authentication.Authentication();
            IMasterTablesDataAccess _repository     = new MasterTablesDataAccess();
            int        response      = 0;
            var        httpRequest   = HttpContext.Current.Request;
            FarmsModel objFarmsModel = new FarmsModel();
            FarmsModel request       = new FarmsModel();

            request = JsonConvert.DeserializeObject <FarmsModel>(httpRequest.Form["farmsdetail"]);
            HttpPostedFile farmimage = httpRequest.Files["farmimage"];

            if (farmimage != null)
            {
                AmazonS3Uploader service = new AmazonS3Uploader();
                request.FarmImages = service.UploadFile("FarmImages/" + request.MobileNumber + farmimage.FileName, new HttpPostedFileWrapper(farmimage));
            }
            HttpPostedFile coverimage = httpRequest.Files["coverimage"];

            if (coverimage != null)
            {
                AmazonS3Uploader service = new AmazonS3Uploader();
                request.CoverPhoto = service.UploadFile("FarmCoverPhotos/" + request.MobileNumber + coverimage.FileName, new HttpPostedFileWrapper(coverimage));
            }
            response = _repository.AddUpdateFarms(request);
            string        Status = "0";
            ResponseModel model  = new ResponseModel();

            if (response > 0)
            {
                model.Status  = response.ToString();
                model.Message = "Farm has been added/updated successfully.";
                UserModel user = new UserModel();
                user = _authrepository.GetUserDetails(request.CreatedBy);
                //var lfd = _repository.GetLookingForDetailsById(request.LookingForDetailsId).LookingForDetails;
                //var models = _repository.GetModelById(request.ModelId).Model;
                //string msg = user.FullName + " is Looking for " + lfd + " of " + models;

                //Notification.SendNotification(request.UserId, WebConfigurationManager.AppSettings["LKF"], msg);
            }
            else
            {
                model.Status = "0";
            }
            return(model);
        }
コード例 #5
0
        public ActionResult CreatedComment(CommentViewModel model)
        {
            var data = new CommentViewModel();

            if (ModelState.IsValid)
            {
                try
                {
                    Comment comment = new Comment();
                    comment = Mapper.Map <Comment>(model);
                    if (model.ListImages != null)
                    {
                        foreach (var item in model.ListImages)
                        {
                            if (string.IsNullOrEmpty(comment.Images))
                            {
                                //Task<string> task = Task.Run<string>(async () => await UploadImageTifiny.TinifyModulAsync(item, TypeUpload.IMAGE));
                                //if (task.Result == "")
                                //	continue;
                                //comment.Images += task.Result;
                                comment.Images += AmazonS3Uploader.UploadFile(item, TypeUpload.IMAGE);
                            }
                            else
                            {
                                //Task<string> task = Task.Run<string>(async () => await UploadImageTifiny.TinifyModulAsync(item, TypeUpload.IMAGE));
                                //if (task.Result == "")
                                //	continue;
                                //comment.Images += "," + task.Result;
                                comment.Images += "," + AmazonS3Uploader.UploadFile(item, TypeUpload.IMAGE);
                            }
                        }
                    }
                    var idCommnet = commentRepository.InsertComment(comment);
                    data = commentRepository.GetCommentByID(idCommnet, userLogin.ID);
                }
                catch (Exception ex)
                {
                    return(Json(new { result = Constant.ERROR }));
                }
            }
            Response.StatusCode = (int)HttpStatusCode.OK;
            return(Json(new { result = Constant.SUCCESS, data }));
        }
コード例 #6
0
 public ActionResult UploadBackGround(string BackGround)
 {
     try
     {
         var user   = userRepository.GetUserByIDForUpdate(userLogin.ID);
         var result = AmazonS3Uploader.UploadFile(BackGround, TypeUpload.IMAGE);
         //Task<string> task = Task.Run<string>(async () => await UploadImageTifiny.TinifyModulAsync(BackGround,TypeUpload.IMAGE));
         //if(result == "" )
         //	return Json(new { result = Constant.ERROR,message = "Error!" });
         user.BackGround = result;
         userRepository.UpdateUser(user);
         userLogin = userRepository.GetUserByID(userLogin.ID);
     }
     catch (Exception ex)
     {
         return(Json(new { result = Constant.ERROR, message = "Error!" }));
     }
     Response.StatusCode = (int)HttpStatusCode.OK;
     return(Json(new { result = Constant.SUCCESS }));
 }
コード例 #7
0
 public ActionResult UploadBackGround(string BackGround, long id)
 {
     try
     {
         var group = groupRepository.GetGroupByIDForUpdate(id);
         //Task<string> task = Task.Run<string>(async () => await UploadImageTifiny.TinifyModulAsync(BackGround,TypeUpload.IMAGE));
         var result = AmazonS3Uploader.UploadFile(BackGround, TypeUpload.IMAGE);
         if (result == "")
         {
             return(Json(new { result = Constant.ERROR, message = "Error!" }));
         }
         group.Banner = result;
         groupRepository.UpdateGroup(group);
     }
     catch (Exception ex)
     {
         return(Json(new { result = Constant.ERROR, message = "Error!" }));
     }
     Response.StatusCode = (int)HttpStatusCode.OK;
     return(Json(new { result = Constant.SUCCESS }));
 }