public ActionResult Delete() { ViewBag.Message = "Profile Delete"; ProfileManagement request = new ProfileManagement(ApiKey) { ExternalProfileID = "testprofile" }; request.PrepareDeleteRequest(); string response; bool success = request.SendRequest(SharedKey, out response); SuccessModel model = new SuccessModel(); dynamic result = JsonConvert.DeserializeObject(response); if (success) { model.UnencryptedData = JsonConvert.SerializeObject(result, Formatting.Indented); } else { TempData.Add("error", JsonConvert.SerializeObject(result, Formatting.Indented)); } return(View(model)); }
public AuthController(IAuthService userService) { _authService = userService; validateMethods = new ValidateMethods(); SuccessModel = new SuccessModel(); ErrorModel = new ErrorModel(); }
public SuccessModel GetVisitorFromIp(string ipAddress) { var successModel = new SuccessModel(); try { using (var db = new OggleBoobleMySqlContext()) { Visitor dbVisitor = db.Visitors.Where(v => v.IpAddress == ipAddress).FirstOrDefault(); if (dbVisitor == null) { successModel.ReturnValue = "not found"; successModel.Success = "ok"; } else { successModel.ReturnValue = dbVisitor.VisitorId; successModel.Success = "ok"; } } } catch (Exception ex) { successModel.Success = Helpers.ErrorDetails(ex); } return(successModel); }
public ActionResult GetPaymentData(string callId) { ViewBag.Message = "Visa Checkout - GetPaymentData result."; ViewBag.CallId = callId; GetPaymentData request = new GetPaymentData(callId, ApiKey) { DataLevel = VisaHelper.Options.DataLevels.FULL }; string response; bool success = request.SendRequest(SharedKey, out response); SuccessModel model = new SuccessModel(); if (success) { dynamic result = JsonConvert.DeserializeObject(response); model.UnencryptedData = JsonConvert.SerializeObject(result, Formatting.Indented); } else { TempData.Add("error", response); } return(View(model)); }
/** * For internal use **/ public void SuccessMessage(string message) { Debug.Log("SuccessMessage received:" + message); SuccessModel model = new SuccessModel(message); OnSuccess(model); }
public BlogController(ITopicService topicService, IBlogService blogService, IMapper mapper) { _topicService = topicService; _blogService = blogService; _mapper = mapper; SuccessModel = new SuccessModel(); ErrorModel = new ErrorModel(); }
public IActionResult Success() { SuccessModel model = new SuccessModel(); model.TransctionCode = Request.Form["id"]; model.PaymentStatus = Request.Form["PaymentStatus"]; return(View(model)); }
// MARK: - Events Methods /* * * Event that will be called with information about successfuly downloaded file. * */ void EventDownloaded(SuccessModel success) { Debug.Log("Downloaded: " + success.mSuccessMessage); actionText.text = "Success: " + success.mSuccessMessage + " State: " + success.mSuccessType + " " + ((success.mFiles != null)?success.mFiles.Length + " files " + success.mFiles[0].mFilePath:" no files"); progressSlider.value = (float)0; }
public SuccessModel LogVisit(string visitorId) { //LogVisitSuccessModel visitSuccessModel = new LogVisitSuccessModel() { VisitAdded = false, IsNewVisitor = false }; SuccessModel successModel = new SuccessModel(); try { using (var db = new OggleBoobleMySqlContext()) { var dbVisitor = db.Visitors.Where(v => v.VisitorId == visitorId).FirstOrDefault(); if (dbVisitor == null) { successModel.ReturnValue = "VisitorId not found"; } else { // { VisitAdded = false, IsNewVisitor = false } DateTime lastVisitDate = DateTime.MinValue; List <Visit> visitorVisits = db.Visits.Where(v => v.VisitorId == visitorId).ToList(); if (visitorVisits.Count() > 0) { lastVisitDate = visitorVisits.OrderByDescending(v => v.VisitDate).FirstOrDefault().VisitDate; } if ((lastVisitDate == DateTime.MinValue) || ((DateTime.Now - lastVisitDate).TotalHours > 12)) { db.Visits.Add(new Visit() { VisitorId = visitorId, VisitDate = DateTime.Now }); db.SaveChanges(); if (visitorVisits.Count() == 0) { successModel.ReturnValue = "new visitor logged"; } else { successModel.ReturnValue = "return visit logged"; } } else { successModel.ReturnValue = "no visit recorded"; } } successModel.Success = "ok"; } } catch (Exception ex) { successModel.Success = Helpers.ErrorDetails(ex); } return(successModel); }
public ActionResult Upload() { SuccessModel viewModel = new SuccessModel(); if (Request.Files.Count == 1) { var name = Request.Files[0].FileName; var size = Request.Files[0].ContentLength; var type = Request.Files[0].ContentType; viewModel.Success = HandleUpload(Request.Files[0].InputStream, name, size, type); } return(Json(viewModel)); }
public ActionResult Success() { var successModel = new SuccessModel(); var url = string.Format( "{0}://{1}{2}{3}", (Request.IsSecureConnection) ? "https" : "http", Request.Url.Host, (Request.Url.Port == 80) ? "" : ":" + Request.Url.Port, VirtualPathUtility.ToAbsolute("~/")); successModel.Website = String.Format("{0}", url); return(View("Success", successModel)); }
public async Task <bool> CreateSuccessAsync(SuccessModel model) { try { await dbcontext.Success.AddAsync(model); dbcontext.SaveChanges(); return(true); } catch (Exception e) { Console.WriteLine(e); return(false); } }
private ActionResult SendRequest(UserManagement request, string sharedKey) { string response; bool success = request.SendRequest(sharedKey, out response); SuccessModel model = new SuccessModel(); dynamic result = JsonConvert.DeserializeObject(response); if (success) { model.UnencryptedData = JsonConvert.SerializeObject(result, Formatting.Indented); } else { TempData.Add("error", JsonConvert.SerializeObject(result, Formatting.Indented)); } return(View(model)); }
public IActionResult Activate([FromBody] UserApprovalModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var response = userService.ActivateUserAccount(model); if (!response.Success) { return(BadRequest(response.Message)); } SuccessModel successModel = new SuccessModel() { Message = response.ReturnedId.ToString() }; return(Ok(successModel)); }
public SuccessModel GetUserCredits(string visitorId) { var successModel = new SuccessModel(); try { using (var db = new OggleBoobleMySqlContext()) { int totalCredits = db.UserCredits.Where(c => c.VisitorId == visitorId).Sum(c => c.Credits); successModel.ReturnValue = totalCredits.ToString(); successModel.Success = "ok"; } } catch (Exception ex) { successModel.Success = Helpers.ErrorDetails(ex); } return(successModel); }
public ActionResult Create() { ViewBag.Message = "Profile Create"; ProfileManagement request = new ProfileManagement(ApiKey) { AcceptCanadianVisaDebit = true, AcceptedRegions = new List <string>() { "US" }, BillingCountries = BillingCountries.US | BillingCountries.AU, CardBrands = SupportedCards.VISA | SupportedCards.AMEX | SupportedCards.DISCOVER | SupportedCards.MASTERCARD, CollectShipping = true, CustomerSupportUrl = new Uri("http://www.test.com"), DefaultProfile = false, ExternalProfileID = "testprofile", LogoDisplayName = "display name", LogoUrl = new Uri("http://www.test.com"), ThreeDSActive = false, ThreeDSSuppressChallenge = false, WebsiteUrl = new Uri("http://www.test.com") }; request.PrepareCreateRequest(); string response; bool success = request.SendRequest(SharedKey, out response); SuccessModel model = new SuccessModel(); dynamic result = JsonConvert.DeserializeObject(response); if (success) { model.UnencryptedData = JsonConvert.SerializeObject(result, Formatting.Indented); } else { TempData.Add("error", JsonConvert.SerializeObject(result, Formatting.Indented)); } return(View(model)); }
public ActionResult Success(string response) { SuccessModel model = new SuccessModel(); ViewBag.Message = "Visa Checkout - Success result."; dynamic result = JsonConvert.DeserializeObject(response); model.EncryptedData = JsonConvert.SerializeObject(result, Formatting.Indented); ResponseHandler handler = new ResponseHandler(); string unencrypted = handler.DecryptPaymentData(SharedKey, result.encKey.ToString(), result.encPaymentData.ToString()); dynamic eData = JsonConvert.DeserializeObject(unencrypted); model.UnencryptedData = JsonConvert.SerializeObject(eData, Formatting.Indented); ViewBag.CallID = result.callid; return(View(model)); }
public SuccessModel AutoIncriment(int folderId, bool recurr) { SuccessModel successModel = new SuccessModel(); int changes = 0; try { using (var db = new OggleBoobleMySqlContext()) { AutoIncrimentRecurr(folderId, recurr, db); } successModel.ReturnValue = changes.ToString(); successModel.Success = "ok"; } catch (Exception ex) { successModel.Success = Helpers.ErrorDetails(ex); } return(successModel); }
public SuccessModel Process(string excelName) { var result = new SuccessModel(); if (HttpContext.Current.Request.Files.Count == 0) { return(result); } var file = HttpContext.Current.Request.Files[0]; excel = new Aspose.Cells.Workbook(file.InputStream); var sheet = excel.Worksheets[0]; var excelId = SaveExcel(excel, excelName); ProcessAccountItem(sheet, excelId); ProcessDatas(sheet, excelId); return(new SuccessModel() { success = true }); }
public async Task <IActionResult> Activate([FromBody] UserApprovalModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } string loginUrl = HttpContext.RequestServices.GetRequiredService <IConfiguration>() .GetValue <String>("LoginUrl"); var response = await userService.ActivateUserAccountAsync(model, loginUrl, defaultUserEmail); if (!response.Success) { return(BadRequest(response.Message)); } SuccessModel successModel = new SuccessModel() { Message = response.ReturnedId.ToString() }; return(Ok(successModel)); }
public ActionResult UpdatePayment(string callId) { ViewBag.Message = "Visa Checkout - UpdatePayment result."; ViewBag.CallId = callId; UpdatePaymentInfo request = new UpdatePaymentInfo(callId, ApiKey) { //OrderInfo = new OrderInfoOptions(101M, CurrencyCodes.USD, 80.1M, EventTypes.Create) //{ // ShippingHandling = 5.1M, // Tax = 7.1M, // Discount = 5.25M, // GiftWrap = 10.1M, // Misc = 3.2M, // OrderID = "testorderID", // PromoCode = "testPromoCode", // Reason = "Order Successfully Created" //}, PayInfo = new PayInfoOptions(PayEventTypes.Authorize, EventStatuses.Success, CurrencyCodes.USD, 101M) { AvsResponseCode = "V" } }; string response; bool success = request.SendRequest(SharedKey, out response); SuccessModel model = new SuccessModel(); dynamic result = JsonConvert.DeserializeObject(response); if (success) { model.UnencryptedData = JsonConvert.SerializeObject(result, Formatting.Indented); } else { TempData.Add("error", JsonConvert.SerializeObject(result, Formatting.Indented)); } return(View(model)); }
public SuccessModel Create(int parentId, string newFolderName, string folderType) { SuccessModel successModel = new SuccessModel(); try { using (var db = new OggleBoobleMySqlContext()) { string ftpRepo = imgRepo.Substring(7); var dbDestParent = db.CategoryFolders.Where(i => i.Id == parentId).First(); string newFtpPath = ftpHost + ftpRepo + "/" + dbDestParent.FolderPath + "/" + newFolderName; if (FtpUtilies.DirectoryExists(newFtpPath)) { successModel.Success = "folder already exists"; return(successModel); } successModel.Success = FtpUtilies.CreateDirectory(newFtpPath); if (successModel.Success == "ok") { CategoryFolder newFolder = new CategoryFolder(); //newFolder.Id = newFolderId; newFolder.Parent = parentId; newFolder.FolderName = newFolderName.Trim(); newFolder.FolderType = folderType; newFolder.RootFolder = dbDestParent.RootFolder; newFolder.SortOrder = 0; newFolder.FolderPath = dbDestParent.FolderPath + "/" + newFolderName; db.CategoryFolders.Add(newFolder); db.SaveChanges(); int newFolderId = newFolder.Id; successModel.ReturnValue = newFolderId.ToString(); successModel.Success = "ok"; } } } catch (Exception ex) { successModel.Success = Helpers.ErrorDetails(ex); } return(successModel); }
public SuccessModel Insert(BlogComment blogComment) { SuccessModel successModel = new SuccessModel(); try { blogComment.Posted = DateTime.Now; using (var db = new OggleBoobleMySqlContext()) { blogComment.Id = Guid.NewGuid().ToString(); db.BlogComments.Add(blogComment); db.SaveChanges(); successModel.Success = "ok"; successModel.ReturnValue = blogComment.Id; } } catch (Exception e) { successModel.Success = Helpers.ErrorDetails(e); } return(successModel); }
public SuccessModel UpdateVisitor(AddVisitorModel visitorData) { var successModel = new SuccessModel(); try { using (var db = new OggleBoobleMySqlContext()) { Visitor dbVisitor = db.Visitors.Where(v => v.VisitorId == visitorData.VisitorId).FirstOrDefault(); if (dbVisitor == null) { successModel.ReturnValue = "not found"; } else { successModel.ReturnValue = "ok"; dbVisitor.City = visitorData.City; dbVisitor.IpAddress = visitorData.IpAddress; dbVisitor.Country = visitorData.Country; dbVisitor.GeoCode = visitorData.GeoCode; dbVisitor.Region = visitorData.Region; if (dbVisitor.InitialPage == 0) { dbVisitor.InitialPage = visitorData.InitialPage; } db.SaveChanges(); } successModel.Success = "ok"; } } catch (Exception ex) { successModel.Success = Helpers.ErrorDetails(ex); } return(successModel); }
public ActionResult <SuccessModel> Create([FromForm] FeedbackModel feedback) { SuccessModel success = null; //DateTime.Now. try { if (feedback.BinaryContent != null && feedback.BinaryContent.Length > 0) { FeedbackTableModel model = new FeedbackTableModel(DateTime.Now.ToLocalTime().ToString("yyyy-MM-dd"), Guid.NewGuid().ToString()) { Email = feedback.Email, Comments = feedback.Comments, EmpId = feedback.EmpId, Link = feedback.Link, TilesName = feedback.TilesName, SubTilesName = feedback.SubTilesName, FileName = feedback.BinaryContent.FileName }; using (var ms = new MemoryStream()) { feedback.BinaryContent.CopyTo(ms); var fileBytes = ms.ToArray(); string s = Convert.ToBase64String(fileBytes); // act on the Base64 data feedbackRepository.Add(model, Convert.FromBase64String(s)); } } else { FeedbackTableModel model = new FeedbackTableModel(DateTime.Now.ToLocalTime().ToString("yyyy-MM-dd"), Guid.NewGuid().ToString()) { Email = feedback.Email, Comments = feedback.Comments, EmpId = feedback.EmpId, Link = feedback.Link, TilesName = feedback.TilesName, SubTilesName = feedback.SubTilesName, FileName = "N/A", BlobUrl = "N/A" }; feedbackRepository.Add(model); } success = new SuccessModel { ResponseCode = "200", ResponseMessage = "Data Uploaded OK" }; } catch (Exception ex) { success = new SuccessModel { ResponseCode = "400", ResponseMessage = ex.Message }; } return(success); }
public TopicController(ITopicService topicService) { _topicService = topicService; SuccessModel = new SuccessModel(); ErrorModel = new ErrorModel(); }
public IActionResult Success(IFormCollection form) { var processor = _paymentService.LoadPaymentMethodBySystemName(IyzicoPayPaymentDefaults.SystemName) as IyzicoPayPaymentProcessor; if (processor == null || !_paymentService.IsPaymentMethodActive(processor) || !processor.PluginDescriptor.Installed) { throw new NopException("Iyzico module cannot be loaded"); } var model = new SuccessModel(); CreateThreedsPaymentRequest threquest = new CreateThreedsPaymentRequest(); threquest.Locale = Locale.TR.ToString(); threquest.PaymentId = form["paymentId"]; threquest.ConversationData = form["conversationData"]; threquest.ConversationId = form["conversationId"]; ThreedsPayment threedsPayment = ThreedsPayment.Create(threquest, HelperApiOptions.GetApiContext(_iyzicoPayPaymentSettings)); if (threedsPayment.Status == "success") { if (form["mdStatus"] == "1") { var customer = _customerService.GetCustomerByGuid(new Guid(threedsPayment.ConversationId)); var query = _orderService.SearchOrders(customerId: customer.Id).ToList(); var order = query.FirstOrDefault(); order.PaymentStatus = threedsPayment.FraudStatus == 1 ? PaymentStatus.Paid : PaymentStatus.Pending; order.OrderStatus = OrderStatus.Processing; order.AuthorizationTransactionId = threedsPayment.PaymentId; order.AuthorizationTransactionCode = threedsPayment.AuthCode; order.PaidDateUtc = DateTime.UtcNow; var paymentrequest = new ProcessPaymentRequest(); var ordernote = new OrderNote(); ordernote.DisplayToCustomer = false; ordernote.CreatedOnUtc = DateTime.UtcNow; ordernote.Note = "Fraud:" + threedsPayment.FraudStatus; paymentrequest.CustomValues.Add("fraudstatus", threedsPayment.FraudStatus); foreach (var item in threedsPayment.PaymentItems) { ordernote.Note += string.Format("{0}{1}", item.ItemId, item.PaymentTransactionId); } order.OrderNotes.Add(ordernote); _orderService.UpdateOrder(order);; _orderService.UpdateOrder(order); if (_orderSettings.OnePageCheckoutEnabled) { return(RedirectToRoute("HomePage")); } return(RedirectToRoute("CheckoutCompleted", new { orderId = order.Id })); } else { switch (form["mdStatus"]) { case "0": model.Errorr = "3-D Secure imzası geçersiz veya doğrulama"; break; case "2": model.Errorr = "Kart sahibi veya bankası sisteme kayıtlı değil"; break; case "3": model.Errorr = "Kartın bankası sisteme kayıtlı değil"; break; case "4": model.Errorr = "Doğrulama denemesi, kart sahibi sisteme daha sonra kayıt olmayı seçmiş"; break; case "5": model.Errorr = "Doğrulama yapılamıyor"; break; case "6": model.Errorr = "3-D Secure hatası"; break; case "7": model.Errorr = "Sistem hatası"; break; case "8": model.Errorr = "Bilinmeyen kart no"; break; default: model.Errorr = "Hata Oluştu"; break; } return(View("~/Plugins/Payments.IyzicoPay/Views/Success.cshtml", model)); } } else { model.Errorr = threedsPayment.ErrorMessage; return(View("~/Plugins/Payments.IyzicoPay/Views/Success.cshtml", model)); } }
public SuccessModel AddImageLink(AddLinkModel addLinkModel) { SuccessModel successModel = new SuccessModel(); try { string mySqlDestPath; string newFileName; string newLink = addLinkModel.Link; string imageLinkId = Guid.NewGuid().ToString(); string extension = newLink.Substring(newLink.LastIndexOf(".")); using (var db = new OggleBoobleMySqlContext()) { if (newLink.IndexOf("?") > 0) { newLink = newLink.Substring(0, newLink.IndexOf("?")); extension = newLink.Substring(newLink.LastIndexOf(".")); } var existingLink = db.ImageFiles.Where(l => l.ExternalLink.Substring(l.ExternalLink.IndexOf(":")) == newLink.Substring(newLink.IndexOf(":"))).FirstOrDefault(); if (existingLink != null) { successModel.Success = "Link Already Added"; return(successModel); } var destinationFolder = db.CategoryFolders.Where(f => f.Id == addLinkModel.FolderId).First(); //mySqlDestPath = db.CategoryFolders.Where(f => f.Id == addLinkModel.FolderId).FirstOrDefault().FolderPath; mySqlDestPath = destinationFolder.FolderPath; if (destinationFolder.FolderType == "singleChild") { var destinationParent = db.CategoryFolders.Where(f => f.Id == destinationFolder.Parent).First(); newFileName = destinationParent.FolderName + "_" + imageLinkId + extension; } else { newFileName = destinationFolder.FolderName + "_" + imageLinkId + extension; } } string appDataPath = System.Web.HttpContext.Current.Server.MapPath("~/App_Data/temp/"); string trimPath = addLinkModel.Path.Replace("/Root/", "").Replace("%20", " "); // USE WEBCLIENT TO CREATE THE FILE using (WebClient wc = new WebClient()) { try { wc.DownloadFile(new Uri(newLink), appDataPath + "tempImage" + extension); } catch { if (newLink.StartsWith("https")) { try { newLink = "http" + newLink.Substring(5); wc.DownloadFile(new Uri(newLink), appDataPath + "tempImage" + extension); } catch (Exception ex) { successModel.Success = "wc. download didnt work " + ex.Message; return(successModel); } } } } // USE WEBREQUEST TO UPLOAD THE FILE FtpWebRequest webRequest = null; try { // todo write the image as a file to x.ogglebooble 4/1/19 //webRequest = (FtpWebRequest)WebRequest.Create(ftpPath + "/" + newFileName); //webRequest.Credentials = networkCredentials; //var zz = webRequest.Method = WebRequestMethods.Ftp.UploadFile; //var mmDom = repoDomain.Substring(8); string destPath = ftpHost + repoDomain.Substring(8) + "/" + mySqlDestPath; if (!FtpUtilies.DirectoryExists(destPath)) { FtpUtilies.CreateDirectory(destPath); } webRequest = (FtpWebRequest)WebRequest.Create(destPath + "/" + newFileName); webRequest.Credentials = networkCredentials; webRequest.Method = WebRequestMethods.Ftp.UploadFile; } catch (Exception ex) { successModel.Success = " webRequest didnt work " + ex.Message; return(successModel); } // TAKE THE WEBREQUEST FILE STREAM TO try { using (Stream requestStream = webRequest.GetRequestStream()) { byte[] fileContents = System.IO.File.ReadAllBytes(appDataPath + "tempImage" + extension); webRequest.ContentLength = fileContents.Length; requestStream.Write(fileContents, 0, fileContents.Length); requestStream.Flush(); requestStream.Close(); } } catch (Exception ex) { successModel.Success = "GetRequestStream didn't work " + ex.Message; return(successModel); } // turn the tempfile into a fileStream to get its size attributes int fWidth = 0; int fHeight = 0; long fSize = 0; try { using (var fileStream = new FileStream(appDataPath + "tempImage" + extension, FileMode.Open, FileAccess.Read, FileShare.Read)) { fSize = fileStream.Length; using (var image = System.Drawing.Image.FromStream(fileStream, false, false)) { fWidth = image.Width; fHeight = image.Height; } } DirectoryInfo directory = new DirectoryInfo(appDataPath); FileInfo tempFile = directory.GetFiles("tempImage" + extension).FirstOrDefault(); if (tempFile != null) { tempFile.Delete(); } System.Diagnostics.Debug.WriteLine("delete worked "); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("delete didn't work " + ex.Message); } using (var db = new OggleBoobleMySqlContext()) { db.ImageFiles.Add(new ImageFile() { Id = imageLinkId, FolderId = addLinkModel.FolderId, ExternalLink = newLink, Width = fWidth, Height = fHeight, Size = fSize, Acquired = DateTime.Now, FileName = newFileName }); //int nextSortOrder = db.CategoryImageLinks.Where(l=>l.ImageCategoryId==addLinkModel.FolderId).Select(Math.Max(sort)) db.CategoryImageLinks.Add(new MySqlDataContext.CategoryImageLink() { ImageCategoryId = addLinkModel.FolderId, ImageLinkId = imageLinkId, SortOrder = 9996 }); db.SaveChanges(); } successModel.Success = "ok"; } catch (Exception ex) { successModel.Success = Helpers.ErrorDetails(ex); } return(successModel); // COPY FILE TO LOCAL ? //try //{ // string localRoot = dbCategory.RootFolder; // if (localRoot == "centerfold") // localRoot = "playboy"; // var test = newLink.Path.Remove(0, newLink.Path.IndexOf("/", newLink.Path.IndexOf("/") + 1)); // var localPath = localRepoPath + localRoot + ".OGGLEBOOBLE.COM" + newLink.Path.Remove(0, newLink.Path.IndexOf("/", newLink.Path.IndexOf("/") + 1)); // DirectoryInfo dirInfo = new DirectoryInfo(localPath); // if (!dirInfo.Exists) // dirInfo.Create(); // wc.DownloadFile(new Uri(newLink.Link), localPath + "/" + newFileName); //} //catch (Exception ex) //{ // var err = Helpers.ErrorDetails(ex); // System.Diagnostics.Debug.WriteLine("wc. download didnt work " + err); //} // see if this is the first image in the folder. If so make it the folder image //try //{ // int lnkCount = db.CategoryImageLinks.Where(c => c.ImageCategoryId == newLink.FolderId).Count(); // if (lnkCount == 0) // successModel.ReturnValue = imageLinkId; // else // successModel.ReturnValue = "0"; //} //catch (Exception ex) //{ // successModel.Success = Helpers.ErrorDetails(ex); // if (successModel.Success.StartsWith("ERROR: Cannot insert duplicate key row in object")) // successModel.Success = "Alredy Added"; //} }
public SuccessModel MoveCopyArchive(MoveCopyImageModel model) { SuccessModel successModel = new SuccessModel(); if (model.SourceFolderId == model.DestinationFolderId) { successModel.Success = "Source and Destination the same"; return(successModel); } try { string imageLinkId; using (var db = new OggleBoobleMySqlContext()) { ImageFile dbImageFile = db.ImageFiles.Where(i => i.Id == model.LinkId).FirstOrDefault(); if (dbImageFile == null) { successModel.Success = "link [" + model.LinkId + "] not found"; return(successModel); } imageLinkId = dbImageFile.Id; var categoryImageLinks = db.CategoryImageLinks.Where(l => l.ImageCategoryId == model.DestinationFolderId).ToList(); if (model.Mode == "Copy") // just add a rec to CategoryImageLink (which should be called File_Image) { MySqlDataContext.CategoryImageLink existingLink = categoryImageLinks.Where(l => l.ImageLinkId == imageLinkId).FirstOrDefault(); if (existingLink != null) { successModel.Success = "Link already exists"; } else { db.CategoryImageLinks.Add(new MySqlDataContext.CategoryImageLink() { ImageCategoryId = model.DestinationFolderId, ImageLinkId = imageLinkId, SortOrder = 999 }); db.SaveChanges(); successModel.Success = "ok"; } } else // Archive / Move { var oldCatImageLink = db.CategoryImageLinks .Where(c => c.ImageCategoryId == model.SourceFolderId && c.ImageLinkId == dbImageFile.Id).First(); db.CategoryImageLinks.Add(new MySqlDataContext.CategoryImageLink() { ImageCategoryId = model.DestinationFolderId, ImageLinkId = dbImageFile.Id, SortOrder = oldCatImageLink.SortOrder }); db.SaveChanges(); if (model.Mode == "Move") { db.CategoryImageLinks.Remove(oldCatImageLink); } db.SaveChanges(); } // determine if this is the first image added to folder successModel.ReturnValue = db.CategoryImageLinks.Where(c => c.ImageCategoryId == model.DestinationFolderId).Count().ToString(); } successModel.Success = "ok"; } catch (Exception ex) { successModel.Success = Helpers.ErrorDetails(ex); } return(successModel); }
public IActionResult Success([FromQuery] SuccessModel model) { return(View(model)); }