예제 #1
0
 public ActionResult GetBalance(Guid? jobOrderId, DateTime? dateFrom, DateTime? dateTo, BalanceViewModel.Scale scale)
 {
     if(!jobOrderId.HasValue || !dateFrom.HasValue || !dateTo.HasValue)
         return new HttpStatusCodeResult(400, "Invalid parameters"); 
     var model = WorkerServices.GetBalanceViewModel(jobOrderId.Value, dateFrom.Value, dateTo.Value, scale);
     //return Json(model, JsonRequestBehavior.AllowGet);
     return Merp.Web.Mvc.JsonNetResult.JsonNet(model);
 }
 public IEnumerable<BalanceViewModel> GetBalanceViewModel(Guid jobOrderId, DateTime dateFrom, DateTime dateTo, BalanceViewModel.Scale scale)
 {
     var model = new List<BalanceViewModel>();
     var step = scale == BalanceViewModel.Scale.Weekly ? 7 : 1;
     foreach (DateTime day in EachDay(dateFrom, dateTo, step))
     {
         var jobOrder = Repository.GetById<Merp.Accountancy.CommandStack.Model.JobOrder, All_JobOrders>(jobOrderId);
         var balance = new BalanceViewModel() { 
                                 Date = day, 
                                 Balance = jobOrder.CalculateBalance(EventStore, day) 
         };
         model.Add(balance);
     }
     return model;
 }