public virtual int GetOrCreateID(string login) { if (string.IsNullOrEmpty(login)) throw new ArgumentException("Login inválido."); int id = DAL.GetIdByLogin(login); if (id == 0) { var professional = new HungryProfessional { Login = login }; DAL.AddProfessional(professional); id = professional.Id; } return id; }
public virtual void AddProfessional(HungryProfessional professional) { professional = LPContext.HungryProfessional.Add(professional); LPContext.SaveChanges(); }