public string getAddressHtml(tbl_address addressItem, AddressHtmlType addressType, DbWithControllerWithMaster helperController) { if (addressItem != null) { switch (addressType) { case AddressHtmlType.agreement: var item = getAddressAccountTemplate(addressItem); return item.content; case AddressHtmlType.mail: case AddressHtmlType.orderDetail: return helperController.RenderRazorViewToString("AddressMailHtml", addressItem); case AddressHtmlType.adminOrderDetail: return ""; } } return ""; }
// Main private addressItem getAddressAccountTemplate(tbl_address item) { addressItem tempItem = new addressItem(); if (item != null) { tempItem.addressId = item.addressId; tempItem.name = item.name; if (item.isPersonal) { tempItem.type = lang.personal; } else { tempItem.type = lang.corporate; } tempItem.content = item.address + "<br />" + item.district + "-" + item.city; } return tempItem; }
public tbl_address addAddress(tbl_address item) { db.tbl_address.Add(item); db.SaveChanges(); return item; }
public Tuple<bool, string> isValidAddress(tbl_address item) { var validationContext = new ValidationContext(item, null, null); var validationResult = new List<ValidationResult>(); Validator.TryValidateObject(item, validationContext, validationResult, true); return getValidationResult(validationResult); }