public ActionResult AddToCart(long product_id, int?product_count) { IcbcodeCart shopping_cart = new IcbcodeCart(HttpContext); var product = IcbcodeContent.Get(product_id); shopping_cart.AddToCart(product_id, product.Link, null, product.Url, product.UserDefined.cena_rub, null, 0); var image = product.GetImage(); var item = new { product_index = shopping_cart.Items.Count, product_id = product_id, product_name = product.Link, product_url = product.Url, product_count = product_count ?? 1, product_price = ((decimal)product.UserDefined.cena_rub).ToString("N0"), product_image = (image == null ? null : image.Url) }; return(Json(item, JsonRequestBehavior.AllowGet)); }
public ActionResult CheckPayment() { var data = IcbcodeUtility.ToDictionary(Request.Form); var signature = IcbcodeCMS.Areas.CMS.Utilities.SignatureHelper.GetSignature("CCF34CBC5A8A479A1DF6FF86AC6B2C43", data); if (signature == data["signature"]) { long orderId = Int64.Parse(data["order_id"]); using (ContentRepository content = new ContentRepository()) { content.Update("oplachen = true", $"content_id = {orderId}"); } var order = IcbcodeContent.Get(orderId); var productItems = new List <ProductItem>(); foreach (var item in order.Childs()) { productItems.Add(new ProductItem() { name = item.Name, price = (decimal)item.UserDefined.cena_rub, quantity = (int)item.UserDefined.kolichestvo, VATrate = 6 }); } EOFD eofd = new EOFD(); eofd.SendCheck(order.UserDefined.email, productItems); IcbcodeUtility.SendEmail(null, null, $"Поступил платеж по заказу №{orderId}", ""); } return(Content("")); }
public ActionResult Checkout(string name, string phone, string email, string address, string delivery_type, string region, string pd, string payment_type) { if (delivery_type == "Почта России") { region = string.Empty; pd = string.Empty; } IcbcodeCart shopping_cart = new IcbcodeCart(HttpContext); var edinici_izmereniya = IcbcodeContent.Get(new long[] { 33455 }); var proizvoditeli = IcbcodeContent.Get(new long[] { 33454 }); Dictionary <string, string> data = null; if (shopping_cart.Items.Count > 0) { StringBuilder body = new StringBuilder(); body.AppendFormat("Имя: {0}", name); body.AppendLine("<br/>"); body.AppendFormat("Телефон: {0}", phone); body.AppendLine("<br/>"); body.AppendFormat("Email: {0}", email); body.AppendLine("<br/>"); body.AppendFormat("Способ доставки: {0}", delivery_type); body.AppendLine("<br/>"); body.AppendFormat("Город / населенный пункт (IML): {0}", region); body.AppendLine("<br/>"); body.AppendFormat("Код ПД (IML): {0}", pd); body.AppendLine("<br/>"); body.AppendFormat("Адрес доставки: {0}", address); body.AppendLine("<br/>"); body.AppendLine("<br/>"); body.AppendLine("<table style=\"border: 1px solid black;\" cellpadding=\"5\" cellspacing=\"5\">"); body.AppendLine("<tr><td>Наименование</td><td>Производитель</td><td>Арт.</td><td>Цена</td><td>Ко-во</td><td>Итого</td></tr>"); decimal price = 0; foreach (var item in shopping_cart.Items) { price += item.item_price * item.item_count; var product = IcbcodeContent.Get(item.item_id); var unit = edinici_izmereniya.Find(x => x.ID == product.UserDefined.edinica_izmereniya).Name; var manufacturer = proizvoditeli.Find(x => x.ID == product.UserDefined.proizvoditelj).Name; body.AppendLine(string.Format("<tr><td><a href=\"{0}\">{1}</a><td>{6}</td><td>{5}</td></td><td>{2}</td><td>{3}</td><td>{4}</td></tr>", string.Format("{0}/{1}", Request.Url.Host, item.item_url), item.item_name, item.item_price, item.item_count, item.item_price * item.item_count, product.UserDefined.artikul, manufacturer)); } decimal delivery_price = 0; price += delivery_price; body.AppendLine($"<tr><td>Доставка: {delivery_type}<td></td><td></td></td><td>{delivery_price}</td><td>1</td><td>{delivery_price}</td></tr>"); body.AppendLine(string.Format("<tr><td> </td><td> </td><td> </td><td> </td><td> </td><td>{0}</td></tr>", price)); body.AppendLine("</table>"); long order_id; using (ContentRepository content = new ContentRepository()) { order_id = content.CreateGlobalID(); string order_url = "/" + order_id.ToString(); content.Create(order_id, null, string.Format("Заказ #{0}", order_id), 33542, order_url, 33543, null, string.Format("fio = '{0}', adres_dostavki = '{1}', telefon = '{2}', email = '{3}', sposob_oplati = '{4}', oplachen = false, summa_rub = {5}, content_publish = now(), sposob_dostavki = '{6}', gorod_naselennij_punkt_iml = '{7}', kod_pd_iml = '{8}'", name, address, phone, email, payment_type, price.ToString("0.00", CultureInfo.InvariantCulture), delivery_type, region, pd), 15984); foreach (var item in shopping_cart.Items) { var product = IcbcodeContent.Get(item.item_id); var position_id = content.CreateGlobalID(); content.Create(position_id, null, item.item_name, 33535, order_url + "/" + position_id.ToString(), 33543, order_id, string.Format("cena_rub = {0}, kolichestvo = {1}, artikul = '{2}', edinica_izmereniya = {3}, proizvoditelj = {4}", item.item_price.ToString("0.00", CultureInfo.InvariantCulture), item.item_count, product.UserDefined.artikul, product.UserDefined.edinica_izmereniya, product.UserDefined.proizvoditelj), 15984); } } data = new Dictionary <string, string>() { { "amount", price.ToString("0.00", CultureInfo.InvariantCulture) }, { "description", $"Заказ №{order_id}" }, { "merchant", "cfde6441-4fb3-46f5-b085-48beacb1beaf" }, { "order_id", order_id.ToString() }, { "testing", "0" }, { "unix_timestamp", ((Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds).ToString() }, { "callback_url", "https://lemil.ru/utility/check-payment" }, { "cancel_url", "https://lemil.ru/k-sozhaleniyu-vi-otmenili-oplatu" }, { "success_url", $"https://lemil.ru/spasibo-vash-zakaz-oplachen" }, { "fail_url", "https://lemil.ru/platezh-zavershilsya-s-oshibkoj" } }; data.Add("signature", IcbcodeCMS.Areas.CMS.Utilities.SignatureHelper.GetSignature("CCF34CBC5A8A479A1DF6FF86AC6B2C43", data)); IcbcodeUtility.SendEmail(null, null, string.Format($"Заказ #{order_id} с сайта lemil.ru"), body.ToString()); shopping_cart.EmptyCart(); } return(View("Pay", data)); }
public ActionResult Index() { string domain = Request.Url.Host; string url = Request.Url.LocalPath; dynamic content = null; using (ContentRepository content_repository = new ContentRepository()) { content = url == "/" ? content_repository.GetActiveMain(domain) : content_repository.GetActiveByUrl(url.TrimEnd('/'), domain); } if (content == null) { throw new HttpException(404, "Not found"); } else { string redirect_url = string.IsNullOrWhiteSpace(content.content_redirect_url) ? Url.Content("~/") : content.content_redirect_url; string view_path = content.view_path; if (content.content_allow_redirect) { return(content.content_redirect_permanent ? RedirectPermanent(redirect_url) : Redirect(redirect_url)); } else if (content.content_export_rss) { var feed = new SyndicationFeed { Title = new TextSyndicationContent(content.content_export_rss_title), Description = new TextSyndicationContent(content.content_export_rss_title), BaseUri = new Uri(string.Format("{0}://{1}{2}", Request.Url.Scheme, Request.Url.Host, content.content_url)), Id = Transliterator.Translite(content.content_export_rss_title, '_'), LastUpdatedTime = DateTime.Now, Items = new List <SyndicationItem>() }; List <SyndicationItem> items = new List <SyndicationItem>(); using (ContentRepository content_repository = new ContentRepository()) { long totals; foreach (var item in content_repository.GetActive(null, ModelUtility.GetLongArray(content.content_export_rss_ids), null, "content_last_update desc", 1, 30, out totals, null, null, domain)) { var syndItem = new SyndicationItem { Title = new TextSyndicationContent(item.content_link ?? item.content_h1), Content = new TextSyndicationContent(IcbcodeUtility.GetPlainText(item.content_short_text)), Id = item.content_id.ToString(), LastUpdatedTime = item.content_publish ?? item.content_last_update }; syndItem.Links.Add(SyndicationLink.CreateAlternateLink(new Uri(string.Format("{0}://{1}{2}", Request.Url.Scheme, Request.Url.Host, item.content_url)))); items.Add(syndItem); } } feed.Items = items; return(new RssActionResult() { Feed = feed }); } else { if (string.IsNullOrWhiteSpace(view_path)) { throw new HttpException(404, "Not found"); } return(View(view_path, IcbcodeContent.Convert(content, 1, 1))); } } }
public ActionResult Edit( // base string guid, long?content_id, long content_block, long?content_root, string template_fields, // main string content_name, string content_url, long content_template, long?content_view, string content_link, // settings bool?content_in_sitemap, bool?content_active, bool?content_main, bool?content_allow_deleted, bool?content_allow_redirect, bool?content_redirect_permanent, string content_redirect_url, // seo string content_title, string content_description, string content_keywords, // rss bool?content_export_rss, string content_export_rss_ids, string content_export_rss_title, // content string content_h1, string content_h2, string content_short_text, string content_text, DateTime?content_publish, // images string[] image_desc, long[] image_ids_for_desc, // files string[] file_desc, long[] file_ids_for_desc, // user fields FormCollection user_fileds) { content_in_sitemap = content_in_sitemap ?? false; content_export_rss = content_export_rss ?? false; content_active = content_active ?? true; content_main = content_main ?? false; content_allow_deleted = content_allow_deleted ?? true; content_allow_redirect = content_allow_redirect ?? false; content_redirect_permanent = content_redirect_permanent ?? false; string user_data = string.Empty; int itemCount = 1; using (FieldRepository field_repository = new FieldRepository()) { List <dynamic> fields = field_repository.GetByIDs(template_fields); foreach (var item in fields) { if (item.field_group != "Пользовательские") { continue; } string value = user_fileds[item.field_name]; if (value != null) { switch ((string)item.field_type) { case "string": case "html": case "tags": value = string.Format("'{0}'", MySql.Data.MySqlClient.MySqlHelper.EscapeString(value)); break; case "date": case "datetime": value = string.IsNullOrWhiteSpace(value) ? null : string.Format("'{0}'", value); break; case "boolean": value = value == "true,false" ? "1" : "0"; break; case "decimal": decimal decimal_val; value = value.Replace(",", "."); if (!Decimal.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out decimal_val)) { value = "0"; } break; case "integer": int int_val; if (!Int32.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out int_val)) { value = "0"; } break; case "list": long list_val; if (!Int64.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out list_val)) { value = null; } break; default: value = value == null ? null : string.Format("'{0}'", value); break; } if (item.field_name == "tirazh_sht") { itemCount = Convert.ToInt32(value); } } user_data += string.Format(",{0} = {1}", item.field_name, value ?? "NULL"); } } List <long> other_ids = null; List <string> promocodes = new List <string>(); using (ContentRepository content_repository = new ContentRepository()) { using (ImageRepository image_repository = new ImageRepository()) { using (FileRepository file_repository = new FileRepository()) { if (content_id.HasValue) { var _old = content_repository.GetByID(content_id.Value); content_repository.Update(content_id.Value, content_in_sitemap.Value, content_export_rss.Value, content_active.Value, content_main.Value, content_allow_deleted.Value, content_name, content_view, content_block, content_title, content_description, content_keywords, content_h1, content_h2, content_short_text, content_text, content_publish, content_root, content_template, content_allow_redirect, content_redirect_permanent, content_redirect_url, content_link, content_export_rss_ids, content_export_rss_title, CurrentUser.domain_id, user_data); } else { for (int z = 0; z < itemCount; z++) { if (content_template == 42528) { do { content_name = IcbcodeUtility.GetPromocode().ToLowerInvariant(); }while (IcbcodeContent.Get(new string[] { "promokodi" }, new string[] { "promokod" }, query: $"content_name = '{content_name}'").Count != 0); } content_id = content_repository.CreateGlobalID(); string parent_url = string.Empty; if (content_root.HasValue) { var content = content_repository.GetByID(content_root.Value); parent_url += content.content_url; } string new_url = parent_url + "/" + Transliterator.Translite(content_url.Substring(0, (content_url.Length > 100 ? 100 : content_url.Length))); if (content_repository.Exists(new_url, CurrentUser.domain_id)) { if (content_template == 42528) { new_url = parent_url + "/" + content_id.ToString(); } else { new_url = new_url + "-" + content_id.ToString(); } } promocodes.Add(content_name); content_repository.Create(content_id.Value, content_in_sitemap.Value, content_export_rss.Value, content_active.Value, content_main.Value, content_allow_deleted.Value, content_name, content_view, new_url, content_block, content_title, content_description, content_keywords, content_h1, content_h2, content_short_text, content_text, content_publish, content_root, content_template, content_allow_redirect, content_redirect_permanent, content_redirect_url, content_link, content_export_rss_ids, content_export_rss_title, CurrentUser.domain_id, user_data); using (TemplateRepository template_repository = new TemplateRepository()) { var current_template = template_repository.GetByID(content_template); if (current_template.template_create_child) { CreateChildsDefaultContent(content_id.Value); } } } if (content_template == 42528) { IcbcodeUtility.SendEmail(null, null, $"Промокоды сгенерированы от {DateTime.Now}", string.Join("<br/>", promocodes)); } } image_repository.Update(content_id.Value, guid); if (image_desc != null && image_ids_for_desc != null && image_desc.Length == image_ids_for_desc.Length) { for (int i = 0; i <= image_ids_for_desc.Length - 1; i++) { image_repository.UpdateDescr(image_ids_for_desc[i], image_desc[i]); } } file_repository.Update(content_id.Value, guid); if (file_desc != null && file_ids_for_desc != null && file_desc.Length == file_ids_for_desc.Length) { for (int i = 0; i <= file_ids_for_desc.Length - 1; i++) { file_repository.UpdateDescr(file_ids_for_desc[i], file_desc[i]); } } if (other_ids != null) { foreach (var other_id in other_ids) { file_repository.RemoveByRef(other_id); if (file_ids_for_desc != null && file_ids_for_desc.Length > 0) { CopyFiles(content_id.Value, other_id); } } } } } } return(RedirectToAction("Index", new { block_id = content_block, content_root = content_root })); }