/// <summary> /// Update an address and the city in the DB /// Business Rules: /// if failed result = 0 /// if successfull result = 1 /// if zipCode invalid result = 2 /// /// </summary> /// <param name="email"></param> /// <param name="zipCode"></param> /// <param name="cityName"></param> /// <param name="streetName"></param> /// <param name="streetNo"></param> /// <param name="addressType"></param> /// <returns></returns> public int UpdateAddress(string email, string zipCode, string cityName, string streetName, string streetNo, string addressType) { Debug.Print("AddressBL: /Update Address: / enter in function"); int result = 0; try { AccountDTO customer = new AccountDTO(); customer = AB.FindBy(email); //if address already exists if (customer.GetAddress() != null) { AddressDTO address = new AddressDTO(); address = DB.FindBy(customer.GetAddress().GetID()); CB.UpdateCity(address.GetCity().GetId(), zipCode, cityName); result = DB.UpdateAddress(address.GetID(), address.GetCity().GetId(), streetName, streetNo, addressType); Debug.Print("AddressBL: /Update Address: / " + result); } else { //if address doesnt exist yet var cityID = CB.Insert(zipCode, cityName); var addressID = DB.Insert(cityID, streetName, streetNo, addressType); result = AB.UpdateAddress(email, addressID); Debug.Print("AddressBL: /Insert Address: / " + result); } } catch (Exception e) { e.GetBaseException(); } return(result); }
public static string UpdateAddress(AddressModel addressModel) { if (AddressDAL.UpdateAddress(addressModel) > 0) { return("收货地址修改成功"); } return("收货地址修改失败"); }
/// <summary> /// Updates a Patient's various records in the db /// </summary> /// <param name="person">Person of the patient to update</param> /// <param name="address">Address of the patient to update</param> /// <param name="patient">Patient to update</param> /// <returns></returns> public bool UpdatePatient(Person person, Address address, Patient patient) { using (TransactionScope scope = new TransactionScope()) { AddressDAL.UpdateAddress(address); PersonDAL.UpdatePerson(person); PatientDAL.UpdatePatient(patient); scope.Complete(); } return(true); }
/// <summary> /// Updates the given Nurse and their information in the db /// </summary> /// <param name="person">The Person of the Nurse to update</param> /// <param name="address">The Address of the Nurse to update</param> /// <param name="nurse">The Nurse to update</param> /// <returns>Whether or not the update succeeded</returns> public bool UpdateNurse(Person person, Address address, Nurse nurse) { using (TransactionScope scope = new TransactionScope()) { AddressDAL.UpdateAddress(address); PersonDAL.UpdatePerson(person); NurseDAL.UpdateNurse(nurse); scope.Complete(); } return(true); }
public ResultBM UpdateAddress(AddressBM addressBm) { try { AddressDAL addressDal = new AddressDAL(); AddressDTO addressDto = null; ResultBM validResult = IsValid(addressBm); if (!validResult.IsValid()) { return(validResult); } addressDto = new AddressDTO(addressBm.id, addressBm.street, addressBm.number, addressBm.apartment, addressBm.neighborhood, addressBm.comment, addressBm.country.iso2); addressDal.UpdateAddress(addressDto); return(new ResultBM(ResultBM.Type.OK, "Dirección actualizada.", addressBm)); } catch (Exception exception) { return(new ResultBM(ResultBM.Type.EXCEPTION, SessionHelper.GetTranslation("UPDATING_ERROR") + " " + exception.Message, exception)); } }
public static bool UpdateAddressBL(Address updateAddress) { bool AddressUpdated = false; try { if (ValidateAddress(updateAddress)) { AddressDAL AddressDAL = new AddressDAL(); AddressUpdated = AddressDAL.UpdateAddress(updateAddress); } } catch (AddressPhoneBookException) { throw; } catch (Exception ex) { throw ex; } return(AddressUpdated); }
public ActionResult UpdateAddress(AddressVM address) { AddressDAL.UpdateAddress(Mapper.Map <AddressDM>(address)); return(View()); }