コード例 #1
0
        public void ProcessRequest(HttpContext objHttpContext)
        {
            string strJSON = new StreamReader(objHttpContext.Request.InputStream).ReadToEnd();

            PostedData objPostedData = JsonConvert.DeserializeObject <PostedData>(strJSON);

            if (objPostedData != null)
            {
                if (objPostedData.ChartType == "CategoryBarChart")
                {
                    Models.User objUser = SessionManager.GetCurrentUser();

                    List <int> listBillIDs = objUser.Bills.Select(y => y.BillID).ToList();

                    List <Bill> listBill = new ApplicationDBContext()
                                           .Bills
                                           .Include("Entries")
                                           .Include("Entries.Category")
                                           .Where(
                        x => listBillIDs.Contains(x.BillID) &&
                        x.PurchaseDate >= objPostedData.From &&
                        x.PurchaseDate <= objPostedData.To)
                                           .ToList();

                    List <ProductCategoryToTotalPrice> listProductCategoryToTotalPrice = new List <ProductCategoryToTotalPrice>();

                    foreach (Bill objBill in listBill)
                    {
                        foreach (BillEntry objBillEntry in objBill.Entries)
                        {
                            int nCategoryIdToCompare = objBillEntry.Category != null ? objBillEntry.Category.ProductCategoryID : -1;
                            int nIndex = listProductCategoryToTotalPrice.FindIndex(x => x.Category.ProductCategoryID == nCategoryIdToCompare);

                            if (nIndex >= 0)
                            {
                                listProductCategoryToTotalPrice[nIndex].Price += objBillEntry.Price;
                            }
                            else
                            {
                                listProductCategoryToTotalPrice.Add(new ProductCategoryToTotalPrice()
                                {
                                    Category = objBillEntry.Category != null ? objBillEntry.Category : Constants.GetDefaultProductCategory(),
                                    Price    = objBillEntry.Price
                                });
                            }
                        }
                    }

                    List <CategoryPieChartSeries> listCategoryPieChartSeries = listProductCategoryToTotalPrice
                                                                               .OrderBy(x => x.Category.Name)
                                                                               .Select(x => new CategoryPieChartSeries(x)).ToList();

                    objHttpContext.Response.ContentType = "application/json";
                    objHttpContext.Response.Write(JsonConvert.SerializeObject(listCategoryPieChartSeries));
                    objHttpContext.Response.Flush();
                    objHttpContext.Response.End();
                }
            }
        }
コード例 #2
0
        public void Post([FromBody] PostedData pos)
        {
            //情報チェック
            if (!LoginHandler.Auth_LoginInfoCheck(pos.LoginInfo))
            {
                throw new Exception("ログイン情報不正");
            }

            //帯を保存
            RegistObiHandler roh = new RegistObiHandler();

            roh.RegistObi(pos.BookData, pos.Imgdata, pos.LoginInfo);
        }
コード例 #3
0
        public async Task <IActionResult> Post([FromBody] PostedData file)
        {
            if (!ModelState.IsValid || file.file == null || file.file == "")
            {
                return(BadRequest(ModelState));
            }

            string currentLocation = Directory.GetCurrentDirectory();
            string fileRoute       = "\\" + file.make + "\\" + file.model + "\\" + file.year + "\\" + file.fix + "\\";
            int    fileNumber      = 0;

            while (System.IO.File.Exists(currentLocation + fileRoute + fileNumber + ".wav"))
            {
                fileNumber++;
            }

            System.IO.File.WriteAllText(currentLocation + fileRoute + fileNumber + ".wav", file.file);

            return(Ok());
        }
コード例 #4
0
 public AjaxContinuation post_update_target(PostedData data)
 {
     return(AjaxContinuation.Successful());
 }