Exemplo n.º 1
0
        public IActionResult DeleteImageComment([FromBody] s_tr deleteData)
        {
            string    folderPath = _environment.WebRootPath;
            RetSimple retSimple  = heritageRepository.DeleteImageComment(deleteData, folderPath);

            return(new JsonResult(retSimple));
        }
Exemplo n.º 2
0
        public IActionResult RemovePhoto([FromBody] Heritage heritage)
        {
            AppSettings appSettings = heritageRepository.GetAppSettings(_config);
            string      folderPath  = _environment.WebRootPath;
            RetSimple   retVal      = new RetSimple {
                success = false, message = "There was problem to remove photo."
            };

            //string card_id = "";
            if (heritage?.hers != null && heritage?.hers.Count > 0)
            {
                retVal = heritageRepository.RemovePhoto((heritage.hers[0]).id, folderPath, appSettings.emptyPhoto);
            }

            return(new JsonResult(retVal));
        }
Exemplo n.º 3
0
        public IActionResult PostHerData([FromBody] s_tr textarea)
        {
            List <string> llist = (textarea.str.Split(new string[] { "\r\n", "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries)).ToList();

            if (llist == null || llist.Count == 0)
            {
                return(new JsonResult(new { success = false, message = "Enter comment before saving." }));
            }

            RetSimple retSimple = heritageRepository.SaveCommentToDB(textarea);

            string        sendStr = "";
            List <string> list_   = new List <string>();

            list_.AddRange(llist);
            //list_.ForEach(t => t  =@"<p>" + t + @"</p>");
            foreach (var item in list_)
            {
                sendStr += @"<p>" + item + @"</p>";
            }

            return(new JsonResult(new { success = true, sendStr = sendStr, order_number = retSimple.Id, card_ids = retSimple.card_ids }));
        }
Exemplo n.º 4
0
        public IActionResult DeleteHeritageLineFrom([FromBody] DeleteData deleteData)
        {
            RetSimple retSimple = heritageRepository.DeleteHeritageLineFrom(deleteData);

            return(new JsonResult(retSimple));
        }
Exemplo n.º 5
0
        public IActionResult PostHerImage(ICollection <IFormFile> files, int User_Id, UploadPhotoViewModel uploadData, string img_comment)
        {
            AppSettings appSettings = heritageRepository.GetAppSettings(_config);
            int         n           = 0;
            string      msg         = "";
            bool        success     = false;
            string      filePath    = "";

            if (files.Count == 0)
            {
                uploadData.message = "Select file for upload!";
                return(View("HerUploadImage", uploadData));
            }

            IFormFile file     = (files.ToList())[0];
            string    fileName = file?.FileName?.Replace(" ", "_").Replace("-", "_");

            if (file?.FileName != null)
            {
                int ii = fileName.LastIndexOf("\\");
                if (ii != -1)
                {
                    fileName = fileName.Substring(ii + 1);
                }
            }

            int i = file.FileName.LastIndexOf(".");

            if (i == -1)
            {
                uploadData.message = "It is not correct file name!!";
                return(View("HerUploadImage", uploadData));
            }
            //string user_name = "63263cc2-119b-4ec5-9f4a-b33a30ecb74b";//????????????   after when authentication
            //string user_name = userIdStr;//????????????   after when authentication
            //filePath = _environment.WebRootPath + @"\Images\Heritage\Temp\" + fileName;

            string folderPath = _environment.WebRootPath + @"\Images\Heritage\Temp\";

            filePath = folderPath + uploadData?.heritageIds + fileName;

            using (var stream = new FileStream(filePath, FileMode.Create))
            {
                try
                {
                    file.CopyTo(stream);
                    n += 1;
                }
                catch (Exception ex)
                {
                    msg += " There was problem to save file :  " + file?.FileName;
                }
            }
            HerRepData herRepData = heritageRepository.ModifyImageStrict(filePath, appSettings.IMAGE_WIDTH, appSettings.IMAGE_HEIGHT, appSettings.userIdStr, imageFormat, ImageModificationsType.WithGivenWidth);
            string     PATH       = herRepData?.path;

            herRepData.path = herRepData?.path?.Substring(herRepData.path.IndexOf("Images") - 1);

            if (!string.IsNullOrWhiteSpace(herRepData?.path))
            {
                bool retVal = heritageRepository.DeleteTempFolderFiles(folderPath);
            }

            if (n > 0 && herRepData.message == "")
            {
                uploadData.height = herRepData?.size.Height ?? 0;
                uploadData.width  = herRepData?.size.Width ?? 0;
                uploadData.path   = herRepData.path.ToLower();
                RetSimple retSimple = heritageRepository.UpdateDBWithImageInfo(uploadData);
                if (retSimple.message != "")
                {
                    uploadData.message = retSimple.message;
                    return(View("HerUploadImage_Data", uploadData));
                }

                msg    += " File saved successfully.";
                success = true;
                return(Json(new
                {
                    success = success,
                    message = msg,
                    path = herRepData.path.ToLower(),
                    height = herRepData?.size.Height,
                    width = herRepData?.size.Width,
                    img_comment = img_comment,
                    order_number = retSimple.Id,
                    card_ids = uploadData.heritageIds
                }));
            }
            else
            {
                uploadData.message = "There was not selected file! \n " + herRepData.message;
                //return Ok(new { count = files.Count, size, filePath });
                return(View("HerUploadImage_Data", uploadData));
            }
        }