public ActionResult Create(InvestingTax taxObj)
        {
            try
            {
                InvestingTax tmp        = taxObj.ShallowCopy();
                DateTime     settleDate = taxObj.tradeDate.AddDays(Constants.Values.MaxWaitingDays);
                tmp.name = taxObj.name.ToUpper();
                if (settleDate.DayOfWeek == DayOfWeek.Sunday)
                {
                    settleDate.AddDays(1);
                }
                else if (settleDate.DayOfWeek == DayOfWeek.Saturday)
                {
                    settleDate.AddDays(2);
                }

                if (settleDate.Month == 7 & settleDate.Day == 1)   // Canada Day
                {
                    settleDate.AddDays(1);
                }

                tmp.settleDate = settleDate;
                _context.InsertNewRec(tmp);
                _context.SaveChanges();

                //Api.AlphaVantageApiWrapper.AlphaVantageRootObject resl = await quotes;
                //return RedirectToAction("Index");
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error in Insert new InvestingTax: " + ex.Message);
                return(Create());
            }


            // db Function TruncateTime created at database side.
            //var records = _context.records.Where(r => DbFunctions.TruncateTime(r.tradeDate)
            //                                                      == DateTime.Today)
            //                                              .Include(r => r._type)
            //                                              .OrderByDescending(r => r.tradeDate)
            //                                              .ToList();
            ViewBag.recList = null;

            ViewBag.DefBuyingCount   = Constants.Values.DefBuyingCount;
            ViewBag.DefCommissionFee = Constants.Values.DefCommissionFee;

            //   var MyStates = new SelectList(new[]
            //{
            //    new { ID="1", Name="name1" },
            //    new { ID="2", Name="name2" },
            //    new { ID="3", Name="name3" },
            //}, "id", "name", -1);
            // ViewBag.MyStates = Newtonsoft.Json.JsonConvert.SerializeObject(MyStates);

            return(View("CreateView2", null));
        }
        public IHttpActionResult CreateInvestingTax(InvestingTax recDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            // var customer = Mapper.Map<CustomerDto, Customer>(customerDto);
            _context.records.Add(recDto);
            _context.SaveChanges();

            // customerDto.Id = customer.Id;
            return(Created(new Uri(Request.RequestUri + "/" + recDto.id), recDto));
        }
Exemple #3
0
 public void InsertNewRec(InvestingTax rec)
 {
     records.Add(rec);
 }