Пример #1
0
        public IDAL.VO.RichiestaRISVO GetRichiestaById(string richidid)
        {
            Stopwatch tw = new Stopwatch();

            tw.Start();

            IDAL.VO.RichiestaRISVO rich = null;
            try
            {
                hlt_ricradiologica rich_ = hltCC.hlt_ricradiologica.Single(t => t.objectid == richidid);
                log.Info(string.Format("Entity Framework Query Executed! Retrieved 1 record!"));
                rich = RichiestaRISMapper.RichMapper(rich_);
                log.Info(string.Format("Record mapped to {0}", rich.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(rich);
        }
Пример #2
0
        public int UpdateRichiestaByPk(IDAL.VO.RichiestaRISVO data, string richidid)
        {
            Stopwatch tw = new Stopwatch();

            tw.Start();

            int result = 0;

            try
            {
                hlt_ricradiologica rich = hltCC.hlt_ricradiologica.First(t => t.objectid == richidid);

                hlt_ricradiologica data_ = RichiestaRISMapper.RichMapper(data);

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

                result = hltCC.SaveChanges();
                log.Info(string.Format("Query Executed! Updated {0} record!", result));
            }
            catch (Exception ex)
            {
                log.Info(string.Format("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);
        }