Exemple #1
0
        private async void DoMoveToDelivery(object obj)
        {
            try
            {
                WorkInProgress = true;
                if (BatchTans != null && SelectedTans != null && SelectedTans.Count() > 0)
                {
                    var InValidTans = SelectedTans.Where(t => (((BatchTanVM)t).TanState.HasValue && S.UnDelivarableTanStates.Contains(((BatchTanVM)t).TanState.Value)) || ((BatchTanVM)t).IsDoubtRaised.ToLower().Equals("true")).ToList();
                    if (InValidTans.Any())
                    {
                        AppInfoBox.ShowInfoMessage("Selected Tan Contains NotAssigned/Curation In progress/Doubt Raised tans.");
                        return;
                    }
                    if (DeliveryBatch != null)
                    {
                        var moveTansDto = new MoveTansDTO();
                        moveTansDto.TanIds         = SelectedTans.Select(t => ((BatchTanVM)t).Id).ToList();
                        moveTansDto.TargetCategory = DeliveryBatch.Id;
                        var status = await RestHub.MoveToDelivery(moveTansDto);

                        if (status.HttpCode == System.Net.HttpStatusCode.OK)
                        {
                            SearchTans.Execute(this);
                            var result = MessageBox.Show(status.StatusMessage, "Status", MessageBoxButton.OKCancel);
                        }
                        else
                        {
                            AppErrorBox.ShowErrorMessage("Can't Move TANs To Delivery . .", status.HttpResponse);
                        }
                    }
                    else
                    {
                        AppInfoBox.ShowInfoMessage("Delivery Batch Not Selected.");
                    }
                }
                else
                {
                    AppInfoBox.ShowInfoMessage("Please Load and Select TANs To Proceed . .");
                }
                WorkInProgress = false;
            }
            catch (Exception ex)
            {
                Log.This(ex);
                AppErrorBox.ShowErrorMessage("Can't Move TANs To Delivery . .", ex.ToString());
            }
            finally
            {
                WorkInProgress = false;
            }
        }
Exemple #2
0
        private async void DoMoveToCategory(object obj)
        {
            try
            {
                WorkInProgress = true;
                if (BatchTans != null && SelectedTans != null && SelectedTans.Count() > 0)
                {
                    if (FromBatch != null && ToCategory != null)
                    {
                        var moveTansDto = new MoveTansDTO();
                        moveTansDto.TanIds         = SelectedTans.Select(t => ((BatchTanVM)t).Id).ToList();
                        moveTansDto.TargetCategory = ToCategory.Value;
                        var status = await RestHub.MoveToCategory(moveTansDto);

                        if (status.HttpCode == System.Net.HttpStatusCode.OK)
                        {
                            SearchTans.Execute(this);
                            var result = MessageBox.Show(status.StatusMessage, "Status", MessageBoxButton.OKCancel);
                        }
                        else
                        {
                            AppErrorBox.ShowErrorMessage("Can't Move TANs To Category . .", status.HttpResponse);
                        }
                    }
                    else
                    {
                        AppInfoBox.ShowInfoMessage("From Batch, To Category Should Be Selected, And Must Be Different To Proceed. .");
                    }
                }
                else
                {
                    AppInfoBox.ShowInfoMessage("Please Load and Select TANs To Proceed . .");
                }
            }
            catch (Exception ex)
            {
                Log.This(ex);
                AppErrorBox.ShowErrorMessage("Can't Move TANs To Category . .", ex.ToString());
            }
            finally
            {
                WorkInProgress = false;
            }
        }
        private async void DoAssignTans(object obj)
        {
            try
            {
                WorkInProgress = true;
                var list          = BatchTansView;
                var filteredItems = BatchTansView.Cast <BatchTanVM>();
                BatchTans = new ObservableCollection <BatchTanVM>();
                if (SelectedCurator != null)
                {
                    if (!string.IsNullOrEmpty(CommentText))
                    {
                        if (SelectedTans != null && SelectedTans.Count > 0)
                        {
                            var      invalidTans     = new List <object>();
                            TanState?tanstateToCheck = null;
                            if (SelectedCurator.Role == Role.Curator)
                            {
                                tanstateToCheck = TanState.Not_Assigned;
                            }
                            else if (SelectedCurator.Role == Role.Reviewer)
                            {
                                tanstateToCheck = TanState.Curation_Submitted;
                            }
                            else if (SelectedCurator.Role == Role.QC)
                            {
                                tanstateToCheck = TanState.Review_Accepted;
                            }
                            if (tanstateToCheck != null)
                            {
                                invalidTans = SelectedTans.Where(st => ((st as BatchTanVM).CurrentRole != 0 && (st as BatchTanVM).CurrentRole != SelectedCurator.Role) ||
                                                                 ((st as BatchTanVM).CurrentRole == 0 && (st as BatchTanVM).TanState != tanstateToCheck)).ToList();
                                if (!invalidTans.Any())
                                {
                                    var result = await RestHub.AssignTans(SelectedTans.Select(tan => (tan as BatchTanVM).Id).ToList(), SelectedCurator.UserId, U.RoleId, CommentText, SelectedRole.Equals("Curator")?Role.Curator : SelectedRole.Equals("Reviewer")?Role.Reviewer : Role.QC);

                                    if (result.UserObject != null)
                                    {
                                        AppInfoBox.ShowInfoMessage($"Tans Assigned to {SelectedRole} Successfully");
                                        SearchTans.Execute(null);
                                    }
                                    else
                                    {
                                        AppErrorBox.ShowErrorMessage("Can't Assign TANs . .", result.StatusMessage);
                                    }
                                }
                                else
                                {
                                    AppInfoBox.ShowInfoMessage($"In selected tans {string.Join(",", invalidTans.Select(tan => (tan as BatchTanVM).TanNumber + " - " + (tan as BatchTanVM).CurrentRole).ToList())} are allocated to other roles");
                                }
                            }
                            else
                            {
                                AppInfoBox.ShowInfoMessage("Please select Role");
                            }
                        }
                        else
                        {
                            AppInfoBox.ShowInfoMessage("Please select atleast One TAN From the below list to Assign TANs");
                        }
                    }
                    else
                    {
                        AppInfoBox.ShowInfoMessage("Please enter comment to Assign Selected TANs");
                    }
                }
                else
                {
                    AppInfoBox.ShowInfoMessage("Please Select User to assign TANs");
                }
            }
            catch (Exception ex)
            {
                Log.This(ex);
            }
            WorkInProgress = false;
        }