public static void DeleteConsultation(Consultation consultation)
 {
     MedicalCardEntities context = new MedicalCardEntities();
     if (consultation.EntityState == EntityState.Detached)
     {
         context.Consultations.Attach(consultation);
     }
     context.Consultations.DeleteObject(consultation);
     context.SaveChanges();
 }
        public static void DeleteConsultation(Consultation consultation)
        {
            MedicalCardEntities context = new MedicalCardEntities();

            if (consultation.EntityState == EntityState.Detached)
            {
                context.Consultations.Attach(consultation);
            }
            context.Consultations.DeleteObject(consultation);
            context.SaveChanges();
        }
        public static void UpdateConsultation(Consultation consultation)
        {
            MedicalCardEntities context = new MedicalCardEntities();

            context.Consultations.AddObject(consultation);
            context.ObjectStateManager.ChangeObjectState(consultation, EntityState.Modified);
            context.SaveChanges();

            //detaching the object - ablity to share between different contexts
            context.Detach(consultation);
        }
        public static void InsertConsultation(Consultation consultation)
        {
            MedicalCardEntities context = new MedicalCardEntities();

            if (consultation.EntityState != EntityState.Detached)
            {
                context.ObjectStateManager.ChangeObjectState(consultation, EntityState.Added);
            }
            else
            {
                context.Consultations.AddObject(consultation);
            }
            context.SaveChanges();
            //detaching the object - ablity to share between different contexts
            context.Detach(consultation);
        }
        public void CreateNew()
        {
            var newConsultation = new Consultation();
            this.Consultation = newConsultation;

            var currentUser = Membership.CurrentUser;

            var currentUserPatient = currentUser.Patient;
            if (currentUserPatient != null)
            {
                this.Consultation.PatientId = currentUserPatient.PatientId;
                this.View.PatientName = currentUserPatient.Name;
                this.View.PatientNumber = currentUserPatient.Number;

            }

            this.FillView();
        }
 /// <summary>
 /// Create a new Consultation object.
 /// </summary>
 /// <param name="consultationId">Initial value of the ConsultationId property.</param>
 public static Consultation CreateConsultation(global::System.Int32 consultationId)
 {
     Consultation consultation = new Consultation();
     consultation.ConsultationId = consultationId;
     return consultation;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Consultations EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToConsultations(Consultation consultation)
 {
     base.AddObject("Consultations", consultation);
 }
 private void SaveModel(Consultation model)
 {
     try
     {
         if (Consultation.ConsultationId == 0)
         {
             ConsultationsDataAccess.InsertConsultation(Consultation);
         }
         else
         {
             ConsultationsDataAccess.UpdateConsultation(Consultation);
         }
         View.Message = "Успешен запис!";
     }
     catch (Exception e)
     {
         var message = String.Format("Възникна грешка при съхраняване! Обадете се на администратор!/n {0} ", e.Message);
         View.Message = message;
     }
 }
 public static void InsertConsultation(Consultation consultation)
 {
     MedicalCardEntities context = new MedicalCardEntities();
     if (consultation.EntityState != EntityState.Detached)
     {
         context.ObjectStateManager.ChangeObjectState(consultation, EntityState.Added);
     }
     else
     {
         context.Consultations.AddObject(consultation);
     }
     context.SaveChanges();
     //detaching the object - ablity to share between different contexts
     context.Detach(consultation);
 }
        public static void UpdateConsultation(Consultation consultation)
        {
            MedicalCardEntities context = new MedicalCardEntities();
            context.Consultations.AddObject(consultation);
            context.ObjectStateManager.ChangeObjectState(consultation, EntityState.Modified);
            context.SaveChanges();

            //detaching the object - ablity to share between different contexts
            context.Detach(consultation);
        }