Esempio n. 1
0
        /// <summary>
        /// Delete entity
        /// </summary>
        /// <param name="id">Entity ID</param>
        /// <returns>Is deleted</returns>
        public bool Delete(int id)
        {
            _logger.TraceMethod(MethodBase.GetCurrentMethod(), id);

            bool deleted = _dbWrapper.Execute <TEnt>(DatabasePath, typeof(TEnt).Name,
                                                     col =>
            {
                return(col.Delete(id));
            });

            _logger.TraceMethodResult(MethodBase.GetCurrentMethod(), deleted);

            return(deleted);
        }
Esempio n. 2
0
        /// <summary>
        /// Loading WCF services plugins by MEF container
        /// </summary>
        /// <param name="container"></param>
        public void LoadServices(CompositionContainer container)
        {
            _logger.TraceMethod(MethodBase.GetCurrentMethod());

            try
            {
                foreach (var service in Services)
                {
                    try
                    {
                        RouteTable.Routes.Add(new ServiceRoute(service.BaseRoute,
                                                               new DI.DependencyInjectionServiceHostFactory(), service.GetType()));
                    }
                    catch (Exception ex)
                    {
                        _logger.Error(ex, string.Format("Error during adding {0} to route {1}", service.GetType().Name, service.BaseRoute));
                    }
                }

                RouteTable.Routes.Add(new ServiceRoute("",
                                                       new DI.DependencyInjectionServiceHostFactory(), typeof(HelpService)));
            }
            catch (Exception ex)
            {
                _logger.ErrorMethod(ex, MethodBase.GetCurrentMethod());
            }
            finally
            {
                _logger.TraceMethodResult(MethodBase.GetCurrentMethod());
            }
        }
Esempio n. 3
0
        protected void Application_Start(object sender, EventArgs e)
        {
            _logger.TraceMethod(MethodBase.GetCurrentMethod());

            try
            {
                // Set MEF catalog
                AggregateCatalog catalog = new AggregateCatalog();
                catalog.Catalogs.Add(new DirectoryCatalog(HttpRuntime.BinDirectory));

                // Create MEF container
                CompositionContainer container = new CompositionContainer(catalog);

                Host host = Host.Instance;
                // Load types marked by Export attribute
                container.ComposeParts(host);
                host.LoadServices(container);
            }
            catch (Exception ex)
            {
                _logger.Fatal(ex, "Error during Application_Start");
            }
            finally
            {
                _logger.TraceMethodResult(MethodBase.GetCurrentMethod());
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Save employee object
        /// </summary>
        /// <param name="entity">Common employee entity</param>
        public void AddEmployee(Employee entity)
        {
            _logger.TraceMethod(MethodBase.GetCurrentMethod(), entity);

            try
            {
                if (IsValid(entity))
                {
                    _employeeRepository.Insert(entity);

                    SetResponseHttpStatus(HttpStatusCode.Created);
                    _logger.TraceMethodResult(MethodBase.GetCurrentMethod(), HttpStatusCode.Created);
                }
                else
                {
                    SetResponseHttpStatus(HttpStatusCode.BadRequest);
                    _logger.TraceMethodResult(MethodBase.GetCurrentMethod(), HttpStatusCode.BadRequest);
                }
            }
            catch (Exception ex)
            {
                _logger.ErrorMethod(ex, MethodBase.GetCurrentMethod());

                SetResponseHttpStatus(HttpStatusCode.InternalServerError);
                _logger.TraceMethodResult(MethodBase.GetCurrentMethod(), HttpStatusCode.InternalServerError);
            }
        }