Ejemplo n.º 1
0
        public IDAL.VO.EsameVO GetEsameById(string esamidid)
        {
            Stopwatch tw = new Stopwatch();

            tw.Start();

            IDAL.VO.EsameVO esam = null;
            try
            {
                long           esamidid_ = long.Parse(esamidid);
                hlt_esameradio esam_     = hltCC.hlt_esameradio.Single(t => t.esameidid == esamidid_);
                log.Info(string.Format("Entity Framework Query Executed! Retrieved 1 record!"));
                esam = EsameMapper.EsamMapper(esam_);
                log.Info(string.Format("Record mapped to {0}", esam.GetType().ToString()));
            }
            catch (Exception ex)
            {
                log.Info(string.Format("Entity Framework Query Executed! Retrieved 0 record!"));
                string msg = "An Error occured! Exception detected!";
                log.Info(msg);
                log.Error(msg + "\n" + ex.Message);
            }

            tw.Stop();

            log.Info(string.Format("Completed! Elapsed time {0}", LibString.TimeSpanToTimeHmsms(tw.Elapsed)));

            return(esam);
        }
Ejemplo n.º 2
0
        public int DeleteEsame(IDAL.VO.EsameVO data)
        {
            Stopwatch tw = new Stopwatch();

            tw.Start();

            int result = 0;

            try
            {
                hlt_esameradio data_ = EsameMapper.EsamMapper(data);
                hltCC.Entry(data_).State = System.Data.EntityState.Deleted;
                result = hltCC.SaveChanges();
                log.Info(string.Format("Entity Framework Query Executed! Deleted {0} record!", result));
            }
            catch (Exception ex)
            {
                log.Info(string.Format("Entity Framework Query Executed! Deleted 0 record!"));
                string msg = "An Error occured! Exception detected!";
                log.Info(msg);
                log.Error(msg + "\n" + ex.Message);
            }

            tw.Stop();

            log.Info(string.Format("Completed! Elapsed time {0}", LibString.TimeSpanToTimeHmsms(tw.Elapsed)));

            return(result);
        }
Ejemplo n.º 3
0
        public int DeleteEsame(string esamidid)
        {
            Stopwatch tw = new Stopwatch();

            tw.Start();

            int result = 0;

            try
            {
                long           esamidid_ = long.Parse(esamidid);
                hlt_esameradio data_     = hltCC.hlt_esameradio.Where(s => s.esameidid == esamidid_).FirstOrDefault <hlt_esameradio>();
                hltCC.Entry(data_).State = System.Data.EntityState.Deleted;
                result = hltCC.SaveChanges();
                log.Info(string.Format("Entity Framework Query Executed! Deleted {0} record!", result));
            }
            catch (Exception ex)
            {
                log.Info(string.Format("Entity Framework Query Executed! Deleted 0 record!"));
                string msg = "An Error occured! Exception detected!";
                log.Info(msg);
                log.Error(msg + "\n" + ex.Message);
            }

            tw.Stop();

            log.Info(string.Format("Completed! Elapsed time {0}", LibString.TimeSpanToTimeHmsms(tw.Elapsed)));

            return(result);
        }
Ejemplo n.º 4
0
        public int AddEsame(Dictionary <string, object> data)
        {
            Stopwatch tw = new Stopwatch();

            tw.Start();

            int result = 0;

            try
            {
                hlt_esameradio esam = new hlt_esameradio();

                foreach (KeyValuePair <string, object> d_ in data)
                {
                    string origPName = d_.Key;
                    object val       = d_.Value;
                    string destPName = origPName;

                    System.Reflection.PropertyInfo prop = esam.GetType().GetProperty(destPName);

                    if (prop != null)
                    {
                        prop.SetValue(esam, Convert.ChangeType(val, prop.PropertyType), null);
                    }
                }

                hltCC.hlt_esameradio.Add(esam);
                result = hltCC.SaveChanges();
                log.Info(string.Format("Entity Framework Query Executed! Added {0} record!", result));
            }
            catch (Exception ex)
            {
                log.Info(string.Format("Entity Framework Query Executed! Added 0 record!"));
                string msg = "An Error occured! Exception detected!";
                log.Info(msg);
                log.Error(msg + "\n" + ex.Message);
            }

            tw.Stop();

            log.Info(string.Format("Completed! Elapsed time {0}", LibString.TimeSpanToTimeHmsms(tw.Elapsed)));

            return(result);
        }
Ejemplo n.º 5
0
        public int UpdateEsameByPk(IDAL.VO.EsameVO data, string esamidid)
        {
            Stopwatch tw = new Stopwatch();

            tw.Start();

            int result = 0;

            try
            {
                long           esamidid_ = long.Parse(esamidid);
                hlt_esameradio esam      = hltCC.hlt_esameradio.First(t => t.esameidid == esamidid_);

                hlt_esameradio data_ = EsameMapper.EsamMapper(data);

                foreach (System.Reflection.PropertyInfo prop in data_.GetType().GetProperties())
                {
                    if (esam.GetType().GetProperty(prop.Name) != null)
                    {
                        object val = prop.GetValue(data_, null);
                        esam.GetType().GetProperty(prop.Name).SetValue(esam, Convert.ChangeType(val, Nullable.GetUnderlyingType(prop.PropertyType) ?? prop.PropertyType), null);
                    }
                }

                result = hltCC.SaveChanges();
                log.Info(string.Format("Entity Framework Query Executed! Updated {0} record!", result));
            }
            catch (Exception ex)
            {
                log.Info(string.Format("Entity Framework Query Executed! Updated 0 record!"));
                string msg = "An Error occured! Exception detected!";
                log.Info(msg);
                log.Error(msg + "\n" + ex.Message);
            }

            tw.Stop();

            log.Info(string.Format("Completed! Elapsed time {0}", LibString.TimeSpanToTimeHmsms(tw.Elapsed)));

            return(result);
        }