Ejemplo n.º 1
0
        /// <summary>
        /// Saves the run.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <returns></returns>
        /// <remarks></remarks>
        public DiagnosticsRunItem SaveRun(DiagnosticsRunItem item)
        {
            var map = new DiagnosticsRunItemMapper();
            var it  = map.MapFromBusinessToService(item);

            try
            {
                using (var scp = new TransactionScope())
                {
                    if (FindRun(item.Id) == null)
                    {
                        DiagnosticsRepositoryAgentFactory
                        .CreateDiagnosticsRunRepositoryAgent()
                        .Insert(it);
                    }
                    else
                    {
                        DiagnosticsRepositoryAgentFactory
                        .CreateDiagnosticsRunRepositoryAgent()
                        .Update(it);
                    }
                    scp.Complete();
                }
            }
            catch (Exception ex)
            {
                if (ex.InnerException != null)
                {
                    item.AddError(ex.InnerException.Message);
                }
                item.AddError(ex.Message);
            }
            return(item);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Finds the run item.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <returns></returns>
        /// <remarks></remarks>
        public DiagnosticsRunItem FindRun(string id)
        {
            var map = new DiagnosticsRunItemMapper();
            var res = DiagnosticsRepositoryAgentFactory
                      .CreateDiagnosticsRunRepositoryAgent()
                      .SelectById(id);

            return((res != null) ? map.MapFromServiceToBusiness(res) : null);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Gets the diagnostics run items for date.
 /// </summary>
 /// <param name="date">The date.</param>
 /// <returns></returns>
 /// <remarks></remarks>
 public DiagnosticsRunItem[] GetDiagnosticsRunItemsForDate(DateTime date)
 {
     using (var scp = new TransactionScope())
     {
         var res = DiagnosticsRepositoryAgentFactory
                   .CreateDiagnosticsRunRepositoryAgent()
                   .SelectByDate(date);
         scp.Complete();
         var map = new DiagnosticsRunItemMapper();
         return(map.MapFromServiceToBusiness(res));
     }
 }