/// <summary> /// /// </summary> /// <param name="model"></param> public void SaveVisitInfo(VisitInfoModel model) { using (var db_context = new iMedDataContext()) { if (0 == model.Id) { var visit_bbdd = new Visit() { ClientId = model.ClientId, Diagnos = model.Diagnos, VisitData = model.DateVisit, VisitType = model.VisitType }; db_context.Visits.Add(visit_bbdd); } else { var visit_bbdd = db_context.Visits.Where(v => v.Id == model.Id). FirstOrDefault(); if (visit_bbdd == null) { throw new IMedDataSourceException(String.Format("Visit with id:{0} not found", model.Id)); } visit_bbdd.ClientId = model.ClientId; visit_bbdd.Diagnos = model.Diagnos; visit_bbdd.VisitData = model.DateVisit; visit_bbdd.VisitType = model.VisitType; } db_context.SaveChanges(); } }
/// <summary> /// /// </summary> /// <param name="id"></param> public void DeleteVisitById(Int32 id) { using (var db_context = new iMedDataContext()) { Visit visit = new Visit() { Id = id }; db_context.Entry(visit).State = EntityState.Deleted; db_context.SaveChanges(); } }
/// <summary> /// /// </summary> /// <param name="id"></param> public void DeleteClientById(Int32 id) { using (var db_context = new iMedDataContext()) { Client client = new Client() { Id = id }; db_context.Entry(client).State = EntityState.Deleted; db_context.SaveChanges(); } }
/// <summary> /// /// </summary> /// <param name="model"></param> public void SaveClientInfo(ClientInfoModel model) { using (var db_context = new iMedDataContext()) { Client client_bbdd = null; if (0 == model.Id) { client_bbdd = new Client(); } else { client_bbdd = db_context.Clients.Where(c => c.Id == model.Id). FirstOrDefault(); if (null == client_bbdd) { throw new IMedDataSourceException(String.Format("Client with id:{0} not found", model.Id)); } } client_bbdd.Name = model.Name; client_bbdd.SecondName = model.SecondName; client_bbdd.ThirdName = model.ThirdName; client_bbdd.DateBirth = model.BirthDay; client_bbdd.Address = model.Address; if (0 == model.Id) { db_context.Clients.Add(client_bbdd); } db_context.SaveChanges(); model.Id = client_bbdd.Id; } }