Example #1
0
        public ParcelsDTO GetCouriersParcels(StorePlace storePlace, int courierId)
        {
            ParcelsDTO result;

            try
            {
                var collection = _storePlaceService.GetCouriersParcels(storePlace, courierId);

                result = new ParcelsDTO
                {
                    StorePlaces = collection,
                    Status      = collection.Count > 0 ? CollectionGetStatus.Success : CollectionGetStatus.Empty
                };
            }
            catch
            {
                result = new ParcelsDTO
                {
                    StorePlaces = null,
                    Status      = CollectionGetStatus.Failure
                };
            }

            return(result);
        }
Example #2
0
        private void CourierWindow_Load(object sender, EventArgs e)
        {
            listBox1.Enabled     = true;
            radioButton1.Checked = false;
            radioButton2.Checked = false;
            radioButton3.Checked = false;
            radioButton4.Checked = false;
            radioButton5.Checked = false;
            radioButton6.Checked = false;
            radioButton7.Checked = false;
            _employee            = _employeeController.GetLoggedEmployee();
            if (_employee != null)
            {
                try
                {
                    listBox1.Items.Clear();
                    if (_employee.ActiveEmployments.Where(em => em.Position.Name.Equals("Administrator")).Count() > 0)
                    {
                        for (int i = 0; i < _parcelController.GetAllParcels().Length; i++)
                        {
                            listBox1.Items.Add(_parcelController.GetAllParcels()[i].Id);
                        }
                    }
                    else
                    {
                        _employment = _employee.ActiveEmployments[0];
                        _storePlace = _employment.StorePlaceId != null?_storePlaceController.GetById(_employment.StorePlaceId.GetValueOrDefault()) : null;

                        _parcelsDTO = _storePlaceController.GetCouriersParcels(_storePlace, _employee.Id);
                        if (_parcelsDTO.Status == CollectionGetStatus.Success)
                        {
                            for (int i = 0; i < _parcelsDTO.StorePlaces.Count; i++)
                            {
                                if (_parcelsDTO.StorePlaces[i].ParcelStatus.Equals(ParcelStatus.OnWayToTheCustomer))
                                {
                                    listBox1.Items.Add(_parcelsDTO.StorePlaces[i].Id);
                                }
                            }
                        }
                    }
                }
                catch (Exception exc)
                {
                    MessageBox.Show(exc.Message);
                }
            }
        }