Example #1
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());
            }
        }
Example #2
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);
            }
        }