Exemplo n.º 1
0
 public void UpdateAddress(int id, AddressModelDC obj)
 {
     if (id < 0)
     {
         throw new ArgumentException(Messages.AddressExceptionGetById);
     }
     this._addressDAL.UpdateAddress(id, obj);
 }
 public Address MapAndSaveAddressModelDCToAddress(Address a, AddressModelDC b)
 {
     a.AddressId = b.addressId;
     a.Address1  = b.address1;
     a.Address2  = b.address2;
     a.ZipId     = b.zipId;
     a.UserId    = b.userId;
     a.IsDeleted = b.isDeleted;
     return(a);
 }
 public AddressModelDC MapAndSaveAddressToAddressModelDC(AddressModelDC a, Address b)
 {
     a.addressId = b.AddressId;
     a.address1  = b.Address1;
     a.address2  = b.Address2;
     a.userId    = b.UserId;
     a.zipId     = b.ZipId;
     a.isDeleted = b.IsDeleted;
     return(a);
 }
 public Address MapToAddress(AddressModelDC a)
 {
     return(new Address()
     {
         //AddressId = a.addressId,
         Address1 = a.address1,
         Address2 = a.address2,
         ZipId = a.zipId,
         UserId = a.userId,
         IsDeleted = a.isDeleted
     });
 }
Exemplo n.º 5
0
 public void AddAddress(AddressModelDC obj)
 {
     if (obj == null)
     {
         throw new ArgumentOutOfRangeException(Messages.AddressExceptionAdd);
     }
     foreach (AddressModelDC address in _addressDAL.GetAddresses())
     {
         if (address.addressId == obj.addressId)
         {
             throw new ArgumentException(Messages.AddressExceptionAdd);
         }
     }
     this._addressDAL.AddAddress(obj);
 }
Exemplo n.º 6
0
 public void AddAddress(AddressModelDC obj)
 {
     foreach (Address address in _db.Addresses)
     {
         if (address.AddressId == obj.addressId)
         {
             throw new ArgumentOutOfRangeException(Messages.AddressExceptionAdd);
         }
     }
     if (obj == null)
     {
         throw new ArgumentOutOfRangeException(Messages.AddressExceptionAdd);
     }
     _db.Addresses.Add(MapToAddress(obj));
     _db.SaveChanges();
 }
Exemplo n.º 7
0
        public void UpdateAddress(int id, AddressModelDC obj)
        {
            if (id < 0)
            {
                throw new ArgumentOutOfRangeException(Messages.AddressExceptionUpdateById);
            }

            Address address = _db.Addresses.FirstOrDefault(x => x.AddressId == id);

            if (address == null)
            {
                throw new ArgumentException(Messages.AddressExceptionUpdateById);
            }

            address = MapAndSaveAddressModelDCToAddress(address, obj);
            _db.SaveChanges();
        }
Exemplo n.º 8
0
 // PUT: api/Address/5
 public void Put(int id, [FromBody] AddressModelDC address)
 {
     addressMethods.UpdateAddress(id, address);
 }
Exemplo n.º 9
0
 // POST: api/Address
 public void Post([FromBody] AddressModelDC address)
 {
     addressMethods.AddAddress(address);
 }