Beispiel #1
0
 public ActionResult <ExpenditureDTO> UpdateExpenditure([FromBody] ExpenditureDTO ex)
 {
     try
     {
         ExpenditureBL.updateExpenditure(ex);
     }
     catch (Exception e)
     {
         return(BadRequest(e.ToString()));
     }
     return(Ok());
 }
Beispiel #2
0
 public ActionResult CancelExpenditure(int ExpenditureId)
 {
     try
     {
         ExpenditureBL.cancelExpenditure(ExpenditureId);
     }
     catch (Exception e)
     {
         return(BadRequest(e.ToString()));
     }
     return(Ok());
 }
 public IHttpActionResult Post([FromBody] Expenditure expenditure)
 {
     try
     {
         ExpenditureBL.Add(expenditure);
         return(Ok());
     }
     catch
     {
         throw;
     }
 }
Beispiel #4
0
        public ActionResult  Getexpenditure()
        {
            List <ExpenditureDTO> expenditures = new List <ExpenditureDTO>();

            try
            {
                expenditures = ExpenditureBL.GetExpendituresList();
            }
            catch (Exception e)
            {
                return(BadRequest(e.ToString()));
            }
            return(Ok(expenditures));
        }
 public HttpResponseMessage AddExpenditure(Expenditure expenditure)
 {
     try
     {
         ExpenditureBL.Add(expenditure);
         if (expenditure.type == (int)ExpenditureType.Irregular)
         {
             PaymentBL.AddPayment(expenditure);
         }
         return(Request.CreateResponse(HttpStatusCode.OK, true));
     }
     catch (Exception ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.ExpectationFailed, ex));
     }
 }
        public HttpResponseMessage GetAllExpenditureGroupDate(int buildingId)
        {
            List <Expenditure> expenditures = ExpenditureBL.GetByBuildingId(buildingId);
            var res = expenditures.GroupBy(p => p.date.Month).ToDictionary(pp => pp.Key, ppp => ppp.Sum(s => s.sum));
            List <ReportExp> reportExps = new List <ReportExp>();

            for (int i = 1; i <= 12; i++)
            {
                double v = 0;
                if (res.ContainsKey(i))
                {
                    v = res[i];
                }
                reportExps.Add(new ReportExp()
                {
                    TypeName = i.ToString(), Value = v
                });
            }
            return(Request.CreateResponse(HttpStatusCode.OK, reportExps));
        }
        public HttpResponseMessage GetAllExpenditureGroupType(int buildingId)
        {
            List <Expenditure> expenditures = ExpenditureBL.GetByBuildingId(buildingId);
            var res = expenditures.GroupBy(p => p.type).ToDictionary(pp => pp.Key, ppp => ppp.Sum(s => s.sum));
            List <ReportExp> reportExps = new List <ReportExp>();

            for (int i = 1; i <= Enum.GetNames(typeof(ExpenditureCategory)).Length; i++)
            {
                double v = 0;
                if (res.ContainsKey(i))
                {
                    v = res[i];
                }
                reportExps.Add(new ReportExp()
                {
                    TypeName = ((ExpenditureCategory)i).GetDescription(), Value = v
                });
            }
            return(Request.CreateResponse(HttpStatusCode.OK, reportExps));
        }
        public HttpResponseMessage CalcPayForMonth(ExpenditureBuilding eb)
        {
            double sum = ExpenditureBL.GetByMonth(eb);

            return(Request.CreateResponse(HttpStatusCode.OK, sum));
        }
        public HttpResponseMessage GetAllExpenditure(int buildingId)
        {
            List <Expenditure> expenditures = ExpenditureBL.GetByBuildingId(buildingId);

            return(Request.CreateResponse(HttpStatusCode.OK, expenditures));
        }
        public HttpResponseMessage GetAllExpenditureCategory()
        {
            Dictionary <int, string> cods = ExpenditureBL.GetCategory();

            return(Request.CreateResponse(HttpStatusCode.OK, cods));
        }
Beispiel #11
0
 public ExpenditureDTO GetexpenditureById([FromRoute] int id)
 {
     return(ExpenditureBL.GetByID(id));
 }
 public Expenditure Get(int id)
 {
     return(ExpenditureBL.GetById(id));
 }
 public List <Expenditure> Get()
 {
     return(ExpenditureBL.Get());
 }