private void AddNewTarget()
        {
            TargetId = Guid.NewGuid();
            var targetItem = new SalesmanTarget
                                 {
                                     Id = TargetId,
                                     PeriodId = SelectedTargetPeriod.Id,
                                     Period = SelectedTargetPeriod.Name,
                                     From = SelectedTargetPeriod.StartDate,
                                     To = SelectedTargetPeriod.EndDate,
                                     Target = Target,
                                     IsQtyTarget = SetAsQty,
                                 };

            SalesmanTargets.Add(targetItem);
        }
        private async void OnDeleteTargetClicked(SalesmanTarget target)
        {
            if (MessageBox.Show("Are you sure you want to delete the selected target?"
                , "Distributr: Delete Outlet Targets"
                , MessageBoxButton.OKCancel) == MessageBoxResult.Cancel)
                return;
            if (SelectedSalesman != null)
            {
                using (StructureMap.IContainer c = NestedContainer)
                {
                    ResponseBool response = null;
                    var proxy = Using<IDistributorServiceProxy>(c);
                    response = await proxy.TargetDeleteAsync(TargetId);

                    MessageBox.Show(response.ErrorInfo, "Distributr:", MessageBoxButton.OK);
                }
            }
            Load();
        }
 private void LoadSalesmanTargets()
 {
     if (SelectedSalesman.CostCentreId != Guid.Empty)
     {
         using (StructureMap.IContainer c = NestedContainer)
         {
             var targets = Using<ITargetRepository>(c).GetAll()
                     .Where(n => n.CostCentre != null && n.CostCentre.Id == SelectedSalesman.CostCentreId
                         && SelectedTargetPeriod != null && n.TargetPeriod.Id == SelectedTargetPeriod.Id)
                     .ToList();
             var items = targets.OrderBy(n => n.TargetPeriod.StartDate)
                 .Select(n =>
                             {
                                 var item = new SalesmanTarget
                                                {
                                                    Id = n.Id,
                                                    PeriodId = n.TargetPeriod.Id,
                                                    Period = n.TargetPeriod.Name,
                                                    From = n.TargetPeriod.StartDate,
                                                    To = n.TargetPeriod.EndDate,
                                                    Target = n.TargetValue,
                                                    IsQtyTarget = n.IsQuantityTarget,
                                                    EntityStatus = (int)n._Status,
                                                };
                                 return item;
                             });
             items.ToList().ForEach(SalesmanTargets.Add);
             var target = items.FirstOrDefault();
             if (target != null)
             {
                 Target = target.Target;
                 TargetId = target.Id;
             }
         }
     }
 }