public Medication AddMed(Medication medication) { var session = HttpContext.Current.Session; if (session["UserId"] != null) { userId = session["UserId"].ToString(); } Medication med = repository.AddMed(medication); EncounterReport erp = new EncounterReport(); erp.RefId = med._id; erp.PatientId = med.UserId; erp.UpdateBy = userId; erp.Action = "Add new Medication"; var encreports = encrepo.AddEncReport(erp); return(med); }