Exemplo n.º 1
0
        public GetCenterResponse GetCenter(GetRequest request)
        {
            GetCenterResponse response = new GetCenterResponse();

            try
            {
                Center center = _centerRepository.FindBy(request.ID);

                if (center != null)
                {
                    CenterView centerView = center.ConvertToCenterView();

                    Infrastructure.Querying.Query query = new Infrastructure.Querying.Query();
                    Criterion criteria = new Criterion("Center.ID", center.ID, CriteriaOperator.Equal);
                    query.Add(criteria);
                    IEnumerable <NetworkCenter>     networkCenters     = _networkCenterRepository.FindBy(query);
                    IEnumerable <NetworkCenterView> networkCenterViews = networkCenters.ConvertToNetworkCenterViews();

                    centerView.NetworkCenters = networkCenterViews;


                    response.CenterView = centerView;
                }
            }
            catch (Exception ex)
            {
                throw;
            }

            return(response);
        }
Exemplo n.º 2
0
        public GeneralResponse EditNetworkCenter(EditNetworkCenterRequest request)
        {
            GeneralResponse response      = new GeneralResponse();
            NetworkCenter   networkCenter = new NetworkCenter();

            Infrastructure.Querying.Query query = new Infrastructure.Querying.Query();
            Criterion criteria1 = new Criterion("Network.ID", request.NetworkID, CriteriaOperator.Equal);
            Criterion criteria2 = new Criterion("Center.ID", request.CenterID, CriteriaOperator.Equal);

            query.Add(criteria1); query.Add(criteria2);

            networkCenter = _networkCenterRepository.FindBy(query).FirstOrDefault();

            if (networkCenter != null)
            {
                try
                {
                    networkCenter.Status  = (NetworkCenterStatus)request.Status;
                    networkCenter.CanSale = request.CanSale;

                    if (networkCenter.GetBrokenRules().Count() > 0)
                    {
                        foreach (BusinessRule businessRule in networkCenter.GetBrokenRules())
                        {
                            response.ErrorMessages.Add(businessRule.Rule);
                        }

                        return(response);
                    }

                    _networkCenterRepository.Save(networkCenter);
                    _uow.Commit();

                    ////response.success = true;
                }
                catch (Exception ex)
                {
                    response.ErrorMessages.Add(ex.Message);
                }
            }
            else
            {
                response.ErrorMessages.Add("NoItemToEditKey");
            }
            return(response);
        }