public GetGeneralResponse <SupportExpertDispatchView> GetSupportExpertDispach(Guid SupportID)
        {
            GetGeneralResponse <SupportExpertDispatchView> response = new GetGeneralResponse <SupportExpertDispatchView>();

            try
            {
                Query     query             = new Query();
                Criterion SupportIDCriteria = new Criterion("Support.ID", SupportID, CriteriaOperator.Equal);
                query.Add(SupportIDCriteria);

                SupportExpertDispatch supportExpertDispatch =
                    _supportExpertDispatchRepository.FindBy(query).FirstOrDefault();

                response.data       = supportExpertDispatch.ConvertToSupportExpertDispatchView();
                response.totalCount = 1;
            }
            catch (Exception ex)
            {
                response.ErrorMessages.Add(ex.Message);
                if (ex.InnerException != null)
                {
                    response.ErrorMessages.Add(ex.InnerException.Message);
                }
            }

            return(response);
        }
        public GeneralResponse AddSupportExpertDispatch(AddSupportExpertDispatchRequest request, Guid CreateemployeeID)
        {
            GeneralResponse response = new GeneralResponse();

            try
            {
                SupportExpertDispatch supportExpertDispatch = new SupportExpertDispatch();

                supportExpertDispatch.ID                = Guid.NewGuid();
                supportExpertDispatch.CreateDate        = PersianDateTime.Now;
                supportExpertDispatch.CreateEmployee    = _employeeRepository.FindBy(CreateemployeeID);
                supportExpertDispatch.Comment           = request.Comment;
                supportExpertDispatch.DispatchDate      = request.DispatchDate;
                supportExpertDispatch.DispatchTime      = request.DispatchTime;
                supportExpertDispatch.ExpertEmployee    = _employeeRepository.FindBy(request.ExpertEmployeeID);
                supportExpertDispatch.CoordinatorName   = request.CoordinatorName;
                supportExpertDispatch.Support           = _supportRepository.FindBy(request.SupportID);
                supportExpertDispatch.Comment           = request.Comment;
                supportExpertDispatch.IsNewInstallation = request.IsNewInstallation;
                supportExpertDispatch.RowVersion        = 1;


                SupportStatusRelation supportStatusRelation = _supportStatusRelationRepository.FindBy(request.SupportStatusID);
                supportExpertDispatch.Support.SupportStatus          = _supportStatusRepository.FindBy(supportStatusRelation.RelatedSupportStatus.ID);
                supportExpertDispatch.Support.Customer.SupportStatus = supportExpertDispatch.Support.SupportStatus;

                if (supportExpertDispatch.Support.SupportStatus.IsLastSupportState)
                {
                    supportExpertDispatch.Support.Closed = true;
                }

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

            return(response);
        }
        public GeneralResponse DeleteSupportExpertDispatch(DeleteRequest request)
        {
            GeneralResponse response = new GeneralResponse();

            try
            {
                SupportExpertDispatch supportExpertDispatch = new SupportExpertDispatch();

                supportExpertDispatch = _supportExpertDispatchRepository.FindBy(request.ID);

                _supportExpertDispatchRepository.Remove(supportExpertDispatch);
                _uow.Commit();
            }
            catch (Exception ex)
            {
                response.ErrorMessages.Add(ex.Message);
                if (ex.InnerException != null)
                {
                    response.ErrorMessages.Add(ex.InnerException.Message);
                }
            }

            return(response);
        }
        public GeneralResponse EditSupportExpertDispatch(EditSupportExpertDispatchRequest request,
                                                         Guid ModifiedEmployeeID)
        {
            GeneralResponse response = new GeneralResponse();

            try
            {
                SupportExpertDispatch supportExpertDispatch = new SupportExpertDispatch();

                supportExpertDispatch                   = _supportExpertDispatchRepository.FindBy(request.ID);
                supportExpertDispatch.Comment           = request.Comment;
                supportExpertDispatch.CoordinatorName   = request.CoordinatorName;
                supportExpertDispatch.DispatchDate      = request.DispatchDate;
                supportExpertDispatch.DispatchTime      = request.DispatchTime;
                supportExpertDispatch.ExpertEmployee    = _employeeRepository.FindBy(request.ExpertEmployeeID);
                supportExpertDispatch.ModifiedDate      = PersianDateTime.Now;
                supportExpertDispatch.ModifiedEmployee  = _employeeRepository.FindBy(ModifiedEmployeeID);
                supportExpertDispatch.IsNewInstallation = request.IsNewInstallation;

                #region Row Version Check

                if (supportExpertDispatch.RowVersion != request.RowVersion)
                {
                    response.ErrorMessages.Add("EditConcurrencyKey");
                    return(response);
                }
                else
                {
                    supportExpertDispatch.RowVersion += 1;
                }

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

                    return(response);
                }


                #endregion


                //supportExpertDispatch.Support.SupportStatus = _supportStatusRepository.FindBy(request.SupportStatusID);
                supportExpertDispatch.Support.Customer.SupportStatus = supportExpertDispatch.Support.SupportStatus;

                _supportExpertDispatchRepository.Save(supportExpertDispatch);
                _uow.Commit();
            }
            catch (Exception ex)
            {
                response.ErrorMessages.Add(ex.Message);
                if (ex.InnerException != null)
                {
                    response.ErrorMessages.Add(ex.InnerException.Message);
                }
            }

            return(response);
        }
Esempio n. 5
0
 public static SupportOwnView ConvertToSupportOwnView(
     this SupportExpertDispatch supportExpertDispatch)
 {
     return(Mapper.Map <SupportExpertDispatch, SupportOwnView>(supportExpertDispatch));
 }