public static void UpdateDiagnosis(Diagnosis diagnosis)
 {
     MedicalCardEntities context = new MedicalCardEntities();
     context.Diagnoses.AddObject(diagnosis);
     context.ObjectStateManager.ChangeObjectState(diagnosis, EntityState.Modified);
     context.SaveChanges();
 }
        public static void UpdateDiagnosis(Diagnosis diagnosis)
        {
            MedicalCardEntities context = new MedicalCardEntities();

            context.Diagnoses.AddObject(diagnosis);
            context.ObjectStateManager.ChangeObjectState(diagnosis, EntityState.Modified);
            context.SaveChanges();
        }
 public static void DeleteDiagnosis(Diagnosis diagnosis)
 {
     MedicalCardEntities context = new MedicalCardEntities();
     if (diagnosis.EntityState == EntityState.Detached)
     {
         context.Diagnoses.Attach(diagnosis);
     }
     context.Diagnoses.DeleteObject(diagnosis);
     context.SaveChanges();
 }
        public static void DeleteDiagnosis(Diagnosis diagnosis)
        {
            MedicalCardEntities context = new MedicalCardEntities();

            if (diagnosis.EntityState == EntityState.Detached)
            {
                context.Diagnoses.Attach(diagnosis);
            }
            context.Diagnoses.DeleteObject(diagnosis);
            context.SaveChanges();
        }
 public static void InsertDiagnosis(Diagnosis diagnosis)
 {
     MedicalCardEntities context = new MedicalCardEntities();
     if (diagnosis.EntityState != EntityState.Detached)
     {
         context.ObjectStateManager.ChangeObjectState(diagnosis, EntityState.Added);
     }
     else
     {
         context.Diagnoses.AddObject(diagnosis);
     }
     context.SaveChanges();
 }
        public static void InsertDiagnosis(Diagnosis diagnosis)
        {
            MedicalCardEntities context = new MedicalCardEntities();

            if (diagnosis.EntityState != EntityState.Detached)
            {
                context.ObjectStateManager.ChangeObjectState(diagnosis, EntityState.Added);
            }
            else
            {
                context.Diagnoses.AddObject(diagnosis);
            }
            context.SaveChanges();
        }
        public void CreateNew()
        {
            var newDiagnosis = new Diagnosis();
            this.Diagnosis = newDiagnosis;

            var currentUser = Membership.CurrentUser;

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

            }

            this.FillView();
        }
 /// <summary>
 /// Create a new Diagnosis object.
 /// </summary>
 /// <param name="diagnoseId">Initial value of the DiagnoseId property.</param>
 public static Diagnosis CreateDiagnosis(global::System.Int32 diagnoseId)
 {
     Diagnosis diagnosis = new Diagnosis();
     diagnosis.DiagnoseId = diagnoseId;
     return diagnosis;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Diagnoses EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToDiagnoses(Diagnosis diagnosis)
 {
     base.AddObject("Diagnoses", diagnosis);
 }
 private void SaveModel(Diagnosis model)
 {
     try
     {
         if (Diagnosis.DiagnoseId == 0)
         {
             DiagnosesDataAccess.InsertDiagnosis(Diagnosis);
         }
         else
         {
             DiagnosesDataAccess.UpdateDiagnosis(Diagnosis);
         }
         View.Message = "Успешен запис!";
     }
     catch (Exception e)
     {
         var message = String.Format("Възникна грешка при съхраняване! Обадете се на администратор!/n {0} ", e.Message);
         View.Message = message;
     }
 }