/// <summary> /// To the model. /// </summary> /// <param name="entity">The entity.</param> /// <returns></returns> public static CitizenshipModel ToModel(this CitizenshipViewModel entity) { if (entity == null) { return(null); } var model = new CitizenshipModel { CitizenshipID = entity.CitizenshipID, Citizenship = entity.Citizenship }; return(model); }
/// <summary> /// To the view model. /// </summary> /// <param name="model">The model.</param> /// <returns></returns> public static CitizenshipViewModel ToViewModel(this CitizenshipModel model) { if (model == null) { return(null); } var entity = new CitizenshipViewModel { CitizenshipID = model.CitizenshipID, Citizenship = model.Citizenship }; return(entity); }
public CitizenshipViewModel CitizenshipView(int id_person) { CitizenshipViewModel result = new CitizenshipViewModel(); var country = Citizenship.GetAll(); var query = country.FirstOrDefault(f => f.id_person == id_person); if (query != null) { result.id_person = query.id_person; result.id_country = query.id_country; result.id_citizenship = query.id_citizenship; } return(result); }