public ActionResult CategoryList() { CategoryDataStore Obj = new CategoryDataStore(); List <SA_Category> NewsList = Obj.GetCategoryList().OrderByDescending(w => w.id).Take(6).ToList(); return(PartialView("~/Views/PartialView/CategoryPartialView.cshtml", NewsList)); }
public ActionResult SaveCategory(SA_Category UserCategory) { for (int i = 0; i < Request.Files.Count; i++) { var file = Request.Files[i]; if (file != null && file.ContentLength > 0) { var fileName = Path.GetFileName(file.FileName); var path = Path.Combine(Server.MapPath("~/ProductImages"), fileName); file.SaveAs(path); UserCategory.CategoryImg = fileName; } } UserCategory.CreatedTime = DateTime.Now; CategoryDataStore Obj = new CategoryDataStore(); if (UserCategory.id == 0) { Obj.AddCategory(UserCategory); } else { Obj.EditCategory(UserCategory); } return(RedirectToAction("Category")); }
public ActionResult ProductList(string id, string search) { NewsDataStore Obj = new NewsDataStore(); DealsDataStore d = new DealsDataStore(); ProductListViewModel model = new ProductListViewModel(); List <SA_News> NewsList = Obj.GetNewsList(); model.NewsList = NewsList; List <SA_Deals> DealList = d.GetDealsList(); model.DealsList = DealList; ProductDataStore p = new ProductDataStore(); IQueryable <SA_Product> ProductList = p.GetProductListBySearch(id, search); model.ProductList = ProductList; CategoryDataStore c = new CategoryDataStore(); if (id != "") { var categoryName = c.GetCategoryByid(Convert.ToInt32(id)); ViewBag.CategoryName = categoryName.CategoryName; } else { ViewBag.CategoryName = ""; } ViewBag.category = c.CategoryList(); return(View("~/Views/ChemAnalyst/products.cshtml", model)); }
public JsonResult CategoryList() { CategoryDataStore Obj = new CategoryDataStore(); List <SA_Category> CategoryList = Obj.GetCategoryList(); return(Json(new { data = CategoryList }, JsonRequestBehavior.AllowGet)); }
// GET: ProductAndCategory /// <summary> /// Get Category data /// </summary> /// <returns></returns> /// public ActionResult Category() { CategoryDataStore Obj = new CategoryDataStore(); //List<SA_Category> CategoryList = Obj.GetCategoryList(); return(View("Category")); }
public override Article CreateArticle(Category category, string owner, string name, string title, string description, string body) { using (TransactionScope transaction = new TransactionScope(mConfiguration)) { ArticleDataStore articleStore = new ArticleDataStore(transaction); if (articleStore.FindByName(name) != null) throw new ArticleNameAlreadyExistsException(name); CategoryDataStore dataStore = new CategoryDataStore(transaction); dataStore.Attach(category); Article article = new Article(category, name, owner, title, description, body); article.Author = owner; if (category.AutoApprove) article.Approved = true; articleStore.Insert(article); transaction.Commit(); return article; } }
public ActionResult AddCategory() { CategoryDataStore ObjDal = new CategoryDataStore(); SA_Category objCatViewModel = new SA_Category(); // objCatViewModel.ProductList = ObjDal.GetProductList(); return(View("add-category", objCatViewModel)); }
public ActionResult AddProduct() { CategoryDataStore ObjDal = new CategoryDataStore(); SA_ProductViewModel obj = new SA_ProductViewModel(); List <SelectListItem> CategoryList = ObjDal.CategoryList(); obj.CategoryList = CategoryList; return(View("add-Product", obj)); }
public override void DeleteCategory(Category category) { using (TransactionScope transaction = new TransactionScope(mConfiguration)) { CategoryDataStore dataStore = new CategoryDataStore(transaction); dataStore.Delete(category.Id); transaction.Commit(); } }
public async void LoadItemId(int itemId) { try { var category = await CategoryDataStore.GetItemAsync(itemId); Text = category.Text; Description = category.Description; SuccessRate = category.SuccessRate; } catch (Exception) { Debug.WriteLine("Failed to Load Category"); } }
public override Category CreateCategory(string name, string displayName) { using (TransactionScope transaction = new TransactionScope(mConfiguration)) { CategoryDataStore dataStore = new CategoryDataStore(transaction); Category category = new Category(name, displayName); dataStore.Insert(category); transaction.Commit(); return category; } }
public ActionResult Create(long?categoryId) { if (!categoryId.HasValue) { var categories = CategoryDataStore.GetAll().ToArray(); return(View("ChooseRequestCategory", categories)); } var cat = CategoryDataStore.Get(categoryId.Value); return(View(new NewRequestFormDto { CategoryId = cat.Id, CategoryName = cat.Name, AuthorId = CurrentOperatorService.GetCurrentUser().Id })); }
public void Create(NewRequestFormDto requestFormDto) { // todo wrap to transaction var category = CategoryDataStore.Get(requestFormDto.CategoryId); var newRequest = new Request { Category = category, Comment = requestFormDto.Comment, Author = UserDataStore.Get(requestFormDto.AuthorId), ConsumerName = requestFormDto.CustemerFio, Date = DateTime.UtcNow, Phone = requestFormDto.PhoneNumber, State = EState.Registered }; RequestDataStore.Save(newRequest); }
public ActionResult EditProduct(int id) { ProductDataStore Obj = new ProductDataStore(); SA_Product obj = Obj.GetProductByid(id); CategoryDataStore Objcat = new CategoryDataStore(); List <SelectListItem> CategoryList = Objcat.CategoryList(); SA_ProductViewModel objSaCatV = new SA_ProductViewModel(); objSaCatV.id = obj.id; objSaCatV.ProductName = obj.ProductName; objSaCatV.ProductDiscription = obj.ProductDiscription; objSaCatV.Meta = obj.Meta; objSaCatV.MetaDiscription = obj.MetaDiscription; objSaCatV.CategoryList = CategoryList; objSaCatV.Category = obj.Category.ToString(); return(View("add-Product", objSaCatV)); }
public ActionResult EditCategory(int id) { CategoryDataStore Obj = new CategoryDataStore(); SA_Category obj = Obj.GetCategoryByid(id); // List<SelectListItem> productList = Obj.GetProductList(); SA_Category objSaCatV = new SA_Category(); objSaCatV.id = obj.id; objSaCatV.CategoryName = obj.CategoryName; objSaCatV.CategoryDiscription = obj.CategoryDiscription; objSaCatV.Meta = obj.Meta; objSaCatV.MetaDiscription = obj.MetaDiscription; objSaCatV.CategoryImg = obj.CategoryImg; // objSaCatV.ProductList = productList; return(View("add-Category", objSaCatV)); }
public ActionResult ProductList() { NewsDataStore Obj = new NewsDataStore(); DealsDataStore d = new DealsDataStore(); ProductListViewModel model = new ProductListViewModel(); List <SA_News> NewsList = Obj.GetNewsList(); model.NewsList = NewsList; List <SA_Deals> DealList = d.GetDealsList(); model.DealsList = DealList; ProductDataStore p = new ProductDataStore(); List <SA_Product> ProductList = p.GetProductList(); model.ProductList = ProductList; CategoryDataStore c = new CategoryDataStore(); ViewBag.category = c.CategoryList(); return(View("~/Views/ChemAnalyst/products.cshtml", model)); }
public ActionResult Reportsection() { string cate = Request.Form["categoryname"] != null ? Request.Form["categoryname"].ToString() : ""; string country = Request.Form["countryname"] != null ? Request.Form["countryname"].ToString() : ""; ViewBag.Cat = cate; ViewBag.Cou = country; CategoryDataStore d = new CategoryDataStore(); IndustryViewModel model = new IndustryViewModel(); List <SA_Industry> IndustryList = Obj.GetIndustryList().Where(x => (cate == "" || cate.Contains(x.CategoryID.ToString() + ",")) && (country == "" || country.Contains(x.CountryID.ToString() + ","))).OrderBy(w => w.id).OrderByDescending(w => w.id).ToList(); model.Industry = IndustryList; List <SelectListItem> lstCategory = d.CategoryList(); model.lstCategory = lstCategory; List <SelectListItem> lstCountry = d.CountryList(); model.lstCountry = lstCountry; return(View("report-section", model)); }
async Task ExecuteLoadCategoriesCommand() { IsBusy = true; try { Categories.Clear(); var items = await CategoryDataStore.GetItemsAsync(true); foreach (var item in items) { Categories.Add(item); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
public ActionResult DeleteCategory(int id) { CategoryDataStore Obj = new CategoryDataStore(); // check if this category is in product ProductDataStore ObjProd = new ProductDataStore(); if (ObjProd.CheckCategory(id)) { TempData["ErrorMessage"] = "You can not delete this category, please delete related product first."; return(RedirectToAction("Category")); } else { if (Obj.DeleteCategory(id) == true) { //return View("Category"); return(RedirectToAction("Category")); } else { return(View("ErrorEventArgs")); } } }
/// <summary> /// Create the topic and the relative root message. /// </summary> /// <param name="category"></param> /// <param name="owner"></param> /// <param name="title"></param> /// <param name="body"></param> /// <param name="attachment">Use null if you don't have any attachment</param> /// <param name="topic">Returns the topic created</param> /// <param name="rootMessage">Returns the message created</param> public override void CreateTopic(Category category, string owner, string title, string body, Attachment.FileInfo attachment, out Topic topic, out Message rootMessage) { //Check attachment if (attachment != null) Attachment.FileHelper.CheckFile(attachment, category.AttachExtensions, category.AttachMaxSize); using (TransactionScope transaction = new TransactionScope(Configuration)) { CategoryDataStore forumStore = new CategoryDataStore(transaction); forumStore.Attach(category); //Insert topic TopicDataStore topicStore = new TopicDataStore(transaction); topic = new Topic(category, owner, title); topicStore.Insert(topic); //Insert root message MessageDataStore messageStore = new MessageDataStore(transaction); rootMessage = new Message(topic, null, owner, title, body, attachment); messageStore.Insert(rootMessage); transaction.Commit(); } }
public override Category GetCategoryByName(string name, bool throwIfNotFound) { using (TransactionScope transaction = new TransactionScope(mConfiguration)) { CategoryDataStore dataStore = new CategoryDataStore(transaction); Category category = dataStore.FindByName(name); if (category == null && throwIfNotFound) throw new WikiCategoryNotFoundException(name); else if (category == null) return null; return category; } }
public override Category GetCategory(string id) { using (TransactionScope transaction = new TransactionScope(mConfiguration)) { CategoryDataStore dataStore = new CategoryDataStore(transaction); Category category = dataStore.FindByKey(id); if (category == null) throw new WikiCategoryNotFoundException(id); return category; } }
public override IList<Category> GetAllCategories() { using (TransactionScope transaction = new TransactionScope(mConfiguration)) { CategoryDataStore dataStore = new CategoryDataStore(transaction); return dataStore.FinAll(); } }
private static void Main(string[] args) { try { var executingDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); var workingDirectory = Directory.GetCurrentDirectory(); var filePath = args.ElementAtOrDefault(0); var outputFilePath = args.ElementAtOrDefault(1) ?? $"{workingDirectory}/out.csv"; var outputJsonFilePath = args.ElementAtOrDefault(1) ?? $"{workingDirectory}/out.json"; if (!string.IsNullOrEmpty(filePath)) { if (!File.Exists(filePath)) { throw new FileNotFoundException($"No file found @ '{filePath}'"); } } else { var inputFiles = Directory.GetFiles(workingDirectory) .Where(f => f.EndsWith("xlsx", StringComparison.OrdinalIgnoreCase) || f.EndsWith("csv", StringComparison.OrdinalIgnoreCase)) .Where(f => !f.EndsWith("out.csv", StringComparison.OrdinalIgnoreCase)) .ToList(); if (inputFiles.Count == 0) { throw new IOException($"No files found in working directory: '{workingDirectory}'"); } if (inputFiles.Count > 1) { throw new IOException($"More than one spreadsheet file was found in working directory: '{workingDirectory}'"); } filePath = inputFiles.Single(); } WriteLine($"ifp: '{filePath}'"); WriteLine($"ofp: '{outputFilePath};"); WriteLine($"ojfp: '{outputJsonFilePath};"); var spreadSheetFactory = new SpreadsheetFactory(); var sheetService = spreadSheetFactory.CreateSpreadsheetServiceFromFilePath(filePath); WriteLine($"ExecutingDir: '{executingDirectory}'"); WriteLine($"WorkingDir: '{workingDirectory}'"); ICategoryDataStore categoryStore = new CategoryDataStore(); var rowData = sheetService.ReadSheet(filePath) .Select(r => new TransactionDto { Type = r["Type"], TransDate = DateTime.Parse(r["Trans Date"]), PostDate = DateTime.Parse(r["Post Date"]), Description = r["Description"], Amount = decimal.Parse(r["Amount"]) * -1 }).ToList(); var groupedInfo = rowData.GroupBy(r => r.Description) .Select(g => { var categoryData = categoryStore.GetCategory(g.Key); return(new { Category = categoryData.Category, Description = categoryData.Description, RecordCount = g.Count(), Sum = g.Sum(x => x.Amount), DescriptionTransactions = g.Select(x => new TransactionDto { Type = x.Type, TransDate = x.TransDate, PostDate = x.PostDate, Description = x.Description, GenericDescription = categoryData.Description, Amount = x.Amount, Category = categoryData.Category }).OrderBy(a => a.TransDate).ToList() }); }) .GroupBy(a => a.Category).Select(g => new { Category = g.Key, RecordCount = g.Count(), CategorySum = g.Sum(x => x.Sum), CategoryTransactions = g.OrderBy(x => x.Description).ToList() }) .OrderBy(a => a.Category); var flattenedData = groupedInfo.SelectMany(g => g.CategoryTransactions) .SelectMany(cts => cts.DescriptionTransactions .Select(tdto => new TransactionDto { Type = tdto.Type, TransDate = tdto.TransDate, PostDate = tdto.PostDate, Description = tdto.Description, GenericDescription = tdto.GenericDescription, Amount = tdto.Amount, Category = cts.Category }) ) .Where(d => !d.Category?.Equals("payments", StringComparison.OrdinalIgnoreCase) ?? true); var writeAbleData = flattenedData.Select(fd => new Dictionary <string, string> { [nameof(fd.Type)] = fd.Type, [nameof(fd.TransDate)] = fd.TransDate.ToString(), [nameof(fd.PostDate)] = fd.PostDate.ToString(), [nameof(fd.Description)] = fd.Description, [nameof(fd.GenericDescription)] = fd.GenericDescription, [nameof(fd.Amount)] = fd.Amount.ToString(), [nameof(fd.Category)] = fd.Category, }); var json = JsonConvert.SerializeObject(groupedInfo, Formatting.Indented); var data = sheetService.WriteSheet(writeAbleData); File.WriteAllBytes(outputFilePath, data); File.WriteAllText(outputJsonFilePath, json); } catch (Exception ex) { WriteLine($"Error: '{ex.Message}'"); } }