コード例 #1
0
        public GeneralResponse UpdateAll()
        {
            GeneralResponse response = new GeneralResponse();

            try
            {
                var centers  = _centerRepository.FindAll();
                var networks = _networkRepository.FindAll();
                foreach (var center in centers)
                {
                    int counter = 0;
                    foreach (var network in networks)
                    {
                        counter++;
                        NetworkCenterPriority networkCenterPriority = new NetworkCenterPriority();
                        networkCenterPriority.Center       = center;
                        networkCenterPriority.Network      = network;
                        networkCenterPriority.SalePriority = counter;
                        _networkCenterPriorityRepository.Add(networkCenterPriority);
                    }
                }
                _uow.Commit();
            }

            catch (Exception ex)
            {
                response.ErrorMessages.Add(ex.Message);
                if (ex.InnerException != null)
                {
                    response.ErrorMessages.Add(ex.InnerException.Message);
                }
            }

            return(response);
        }
コード例 #2
0
ファイル: CenterService.cs プロジェクト: zafariNet/Saman
        public GeneralResponse AddCenter(IEnumerable <AddCenterRequest> requests, Guid CreateEmployeeID)
        {
            GeneralResponse response = new GeneralResponse();

            try
            {
                foreach (var request in requests)
                {
                    Center center = new Center();
                    center.ID             = Guid.NewGuid();
                    center.CreateDate     = PersianDateTime.Now;
                    center.CreateEmployee = _employeeRepository.FindBy(CreateEmployeeID);
                    center.CenterName     = request.CenterName;
                    center.Note           = request.Note;
                    center.RowVersion     = 1;

                    _centerRepository.Add(center);

                    // be jaye Triggere After Insert. NetworkCenter-ha insert mishavad
                    IList <NetworkCenter> networkCenters = new List <NetworkCenter>();
                    foreach (Network network in _networkRepository.FindAll())
                    {
                        NetworkCenter networkCenter = new NetworkCenter();
                        networkCenter.Network        = network;
                        networkCenter.Center         = center;
                        networkCenter.CreateDate     = PersianDateTime.Now;
                        networkCenter.CreateEmployee = center.CreateEmployee;
                        networkCenter.Status         = NetworkCenterStatus.NotDefined;
                        networkCenter.RowVersion     = 1;

                        networkCenters.Add(networkCenter);
                    }

                    center.NetworkCenters = networkCenters;

                    #region Validation

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

                        return(response);
                    }

                    #endregion

                    _centerRepository.Add(center);
                }
                _uow.Commit();
            }
            catch (Exception ex)
            {
                response.ErrorMessages.Add(ex.Message);
            }

            return(response);
        }
コード例 #3
0
ファイル: NetworkService.cs プロジェクト: zafariNet/Saman
        public GetNetworksResponse GetNetworks()
        {
            GetNetworksResponse response = new GetNetworksResponse();

            try
            {
                IEnumerable <NetworkView> networks = _networkRepository.FindAll()
                                                     .ConvertToNetworkViews();

                response.NetworkViews = networks;
            }
            catch (Exception ex)
            {
                throw;
            }

            return(response);
        }