public PhoneModel Create(Phone phone) { return new PhoneModel { Number = phone.Number }; }
public Phone Parse(int userId, PhoneModel phoneModel) { try { var phone = new Phone(); if (!string.IsNullOrEmpty(phoneModel.Number)) { phone.Number = phoneModel.Number; } if (context.Users.Any(u => u.Id == userId)) { phone.UserID = userId; } return phone; } catch (Exception ex) { return null; } }