/// <summary> /// Create Famer object from FamerModel /// </summary> /// <returns></returns> public Famer CreateEntity() { Famer famer = new Famer(); famer.Id = this.FamerId; famer.PersonalId = this.PersonalId; famer.Personal = new Personal(); famer.Personal.Id = this.PersonalId; famer.Personal.FullName = this.FullName; famer.Personal.Address = this.Address; famer.Personal.Sex = this.Sex == (int)SexEnum.Male ? true : false; famer.Personal.BirthDay = this.BirthDay; famer.Personal.Phone = this.Phone; famer.Personal.Description = this.Description; return(famer); }
/// <summary> /// Create FamerModel from Famer object /// </summary> /// <param name="famer"></param> /// <returns></returns> public static FamerModel GetModel(Famer famer) { if (famer.Personal == null) { return(null); } FamerModel model = new FamerModel(); model.FamerId = famer.Id; model.PersonalId = famer.PersonalId; model.FullName = famer.Personal.FullName; model.Address = famer.Personal.Address; model.Sex = famer.Personal.Sex == true ? (int)SexEnum.Male : (int)SexEnum.Female; model.BirthDay = famer.Personal.BirthDay; model.Phone = famer.Personal.Phone; model.Description = famer.Personal.Description; model.HaveAccount = famer.Personal.ApplicationUser != null ? true : false; return(model); }