Exemple #1
0
 public examination add(examination acc)
 {
     try
     {
         _context.examinations.Add(acc);
         _context.SaveChanges();
     }
     catch (Exception e)
     {
         Logger.Log(e.ToString(), LogType.Error);
     }
     return(acc);
 }
Exemple #2
0
 public visit add(visit acc)
 {
     try
     {
         _context.visits.Add(acc);
         _context.SaveChanges();
     }
     catch (Exception e)
     {
         Logger.Log(e.ToString(), LogType.Error);
     }
     return(acc);
 }
Exemple #3
0
 public Specialization add(Specialization acc)
 {
     try
     {
         _context.Specializations.Add(acc);
         _context.SaveChanges();
         Logger.Log(acc.name + " is Added", LogType.Info);
     }
     catch (Exception e)
     {
         Logger.Log(e.ToString(), LogType.Error);
     }
     return(acc);
 }
 public override Account add(Account acc)
 {
     try
     {
         _context.Accounts.Add(acc);
         _context.SaveChanges();
         Logger.Log(acc.name + " is Added", LogType.Info);
     }
     catch (Exception e)
     {
         Logger.Log(e.ToString(), LogType.Error);
     }
     return(acc);
 }
Exemple #5
0
 public Lab add(Lab acc)
 {
     try
     {
         _context.Labs.Add(acc);
         _context.SaveChanges();
         Logger.Log(acc.Name + " is Added", LogType.Info);
     }
     catch (Exception e)
     {
         Logger.Log(e.ToString(), LogType.Error);
     }
     return(acc);
 }
Exemple #6
0
 public medicine add(medicine acc)
 {
     try
     {
         _context.medicines.Add(acc);
         _context.SaveChanges();
         Logger.Log(acc.commercialName + " is Added", LogType.Info);
     }
     catch (Exception e)
     {
         Logger.Log(e.ToString(), LogType.Error);
     }
     return(acc);
 }
 public Endoscopy add(Endoscopy acc)
 {
     try
     {
         _context.Endoscopies.Add(acc);
         _context.SaveChanges();
         Logger.Log(acc.Endoscopy1 + " is Added", LogType.Info);
     }
     catch (Exception e)
     {
         Logger.Log(e.ToString(), LogType.Error);
     }
     return(acc);
 }
 public Imaging add(Imaging acc)
 {
     try
     {
         _context.Imagings.Add(acc);
         _context.SaveChanges();
         Logger.Log(acc.ImageName + " is Added", LogType.Info);
     }
     catch (Exception e)
     {
         Logger.Log(e.ToString(), LogType.Error);
     }
     return(acc);
 }
Exemple #9
0
 public surgicalHistory add(surgicalHistory acc)
 {
     try
     {
         _context.surgicalHistories.Add(acc);
         _context.SaveChanges();
         Logger.Log(acc.operationName + " is Added", LogType.Info);
     }
     catch (Exception e)
     {
         Logger.Log(e.ToString(), LogType.Error);
     }
     return(acc);
 }
 public Complaint add(Complaint acc)
 {
     try
     {
         _context.Complaints.Add(acc);
         _context.SaveChanges();
         Logger.Log(acc.complaintName + " is Added", LogType.Info);
     }
     catch (Exception e)
     {
         Logger.Log(e.ToString(), LogType.Error);
     }
     return(acc);
 }
Exemple #11
0
        public SystemPerson edit(SystemPerson acc)
        {
            try
            {
                DBService <Account> _accountService = new AccountService();
                Account             account         = _accountService.get(acc.id);
                if (account != null)
                {
                    account.name     = acc.name;
                    account.password = acc.Password;
                    _accountService.edit(account);
                }
                else
                {
                    addAccount(acc);
                }

                var entry = _context.Entry <SystemPerson>(acc);

                if (entry.State == System.Data.Entity.EntityState.Detached)
                {
                    var          set            = _context.Set <SystemPerson>();
                    SystemPerson attachedEntity = set.Local.SingleOrDefault(e => e.id == acc.id);  // You need to have access to key

                    if (attachedEntity != null)
                    {
                        var attachedEntry = _context.Entry(attachedEntity);
                        attachedEntry.CurrentValues.SetValues(acc);
                    }
                    else
                    {
                        entry.State = System.Data.Entity.EntityState.Modified; // This should attach entity
                    }
                }
                _context.SaveChanges();
                Logger.Log(acc.name + " is Edited", LogType.Info);
            }
            catch (Exception e)
            {
                Logger.Log(e.ToString(), LogType.Error);
            }
            return(acc);
        }