Esempio n. 1
0
        public async Task <IActionResult> Post([FromBody] SaveReservationDto saveReservation)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var id = await reservations.Save(saveReservation.ToModel());

            return(Ok(id));
        }
Esempio n. 2
0
 public static Reservation ToModel(this SaveReservationDto dto)
 {
     return(new Reservation
     {
         Date = dto.DateTime,
         Description = dto.Description,
         Vendor = new Vendor
         {
             Name = dto.Vendor
         },
         Expense = new Domain.Models.Expense
         {
             CostCentre = dto.Expense.CostCentre,
             PaymentMethod = dto.Expense.PaymentMethod,
             Total = dto.Expense.Total,
             Gst = Math.Round(dto.Expense.Total * 0.15m, 2)
         }
     });
 }