Beispiel #1
0
        public SalesPersonDto AllocateSalesPerson(
            [FromBody] CustomerPreferenceDto customerPreference)
        {
            var allocation = _salesPersonAllocator
                             .GetAllocation(customerPreference.ToDomainEntity());

            return(allocation == null
                ? SalesPersonDto.Empty()
                : SalesPersonDto.FromDomainEntity(allocation));
        }
 public IActionResult Post([FromBody] SalesPersonDto dto)
 {
     try
     {
         provider.Create(dto.toDao());
         return(Ok("Salesperson created succsessfully."));
     }
     catch (Exception e)
     {
         return(BadRequest($"ERROR: {e.Message}"));
     }
 }
 public IActionResult Put(int id, [FromBody] SalesPersonDto dto)
 {
     try
     {
         provider.Update(dto.toDao());
         return(Ok("Salesperson updated successfully!"));
     }
     catch (Exception e)
     {
         return(BadRequest($"ERROR: {e.Message}"));
     }
 }
 /// <summary>
 /// Maps a DTO Object back to a DAO.
 /// </summary>
 /// <param name="salespersondto">DTO SalesPerson Object</param>
 /// <returns>Mapped DAO SalesPerson Object</returns>
 public static SalesPerson toDao(this SalesPersonDto salespersondto)
 {
     if (salespersondto != null)
     {
         return(new SalesPerson()
         {
             ID = salespersondto.ID,
             Name = salespersondto.Name,
             Surname = salespersondto.Surname
         });
     }
     return(null);
 }