Exemplo n.º 1
0
 public IHttpActionResult Put(int id, [FromBody] DAO.Address address)
 {
     try
     {
         if (address == null)
         {
             return(BadRequest());
         }
         //map
         var ad     = _addressFactory.CreateAddress(address);
         var result = _repository.UpdateAddress(ad);
         if (result.Status == BookingRepositoryActionStatus.Updated)
         {
             // map to dao
             var updatedAddress = _addressFactory.CreateAddress(result.Entity);
             return(Ok(updatedAddress));
         }
         else if (result.Status == BookingRepositoryActionStatus.NotFound)
         {
             return(NotFound());
         }
         return(BadRequest());
     }
     catch (Exception)
     {
         return(InternalServerError());
     }
 }
Exemplo n.º 2
0
        public Address CreateAddress(DAO.Address address)
        {
            return(new Address()
            {
                Id = address.Id,
                Address1 = address.Address1,
                Address2 = address.Address2,
                CityId = address.CityId,
                Distric = address.Distric,
                ZipCode = address.ZipCode,
                Phone = address.Phone,
                BusinessId = address.BusinessId,
                LastUpdate = address.LastUpdate

                             //Businesses = address.Businesses == null ? new List<Business>() : address.Businesses.Select(b => businessFactory.CreateBusiness(b)).ToList()
            });
        }
Exemplo n.º 3
0
 public IHttpActionResult Post([FromBody] DAO.Address address)
 {
     try
     {
         if (address == null)
         {
             return(BadRequest());
         }
         var a      = _addressFactory.CreateAddress(address);
         var result = _repository.InsertAddress(a);
         if (result.Status == BookingRepositoryActionStatus.Created)
         {
             var newAddress = _addressFactory.CreateAddress(result.Entity);
             return(Created(Request.RequestUri + "/" + newAddress.Id.ToString(), newAddress));
         }
         return(BadRequest());
     }
     catch (Exception)
     {
         return(InternalServerError());
     }
 }