public GetGeneralResponse <SupportDeliverServiceView> GetSupportDeliverService(Guid SupportID) { GetGeneralResponse <SupportDeliverServiceView> response = new GetGeneralResponse <SupportDeliverServiceView>(); try { Query query = new Query(); Criterion supportIDCriteria = new Criterion("Support.ID", SupportID, CriteriaOperator.Equal); query.Add(supportIDCriteria); SupportDeliverService supportDeliverService = _supportDeliverServiceRepository.FindBy(query).FirstOrDefault(); response.data = supportDeliverService.ConvertToSupportDeliverServiceView(); 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 EditSupportDeliverService(EditSupportDeliverServiceRequest request, Guid ModifiedEmployeeID) { GeneralResponse response = new GeneralResponse(); try { SupportDeliverService supportDeliverService = new SupportDeliverService(); supportDeliverService = _supportDeliverServiceRepository.FindBy(request.ID); supportDeliverService.AmountRecived = request.AmountRecived; supportDeliverService.Comment = request.Comment; supportDeliverService.DeliverDate = request.DeliverDate; supportDeliverService.TimeInput = request.TimeInput; supportDeliverService.TimeOutput = request.TimeOutput; supportDeliverService.ModifiedDate = PersianDateTime.Now; supportDeliverService.ModifiedEmployee = _employeeRepository.FindBy(ModifiedEmployeeID); #region Row Version Check if (supportDeliverService.RowVersion != request.RowVersion) { response.ErrorMessages.Add("EditConcurrencyKey"); return(response); } else { supportDeliverService.RowVersion += 1; } if (supportDeliverService.GetBrokenRules().Count() > 0) { foreach (BusinessRule businessRule in supportDeliverService.GetBrokenRules()) { response.ErrorMessages.Add(businessRule.Rule); } return(response); } #endregion _supportDeliverServiceRepository.Save(supportDeliverService); _uow.Commit(); } catch (Exception ex) { response.ErrorMessages.Add(ex.Message); if (ex.InnerException != null) { response.ErrorMessages.Add(ex.InnerException.Message); } } return(response); }
public GeneralResponse DeleteSupportDeliverService(DeleteRequest request) { GeneralResponse response = new GeneralResponse(); try { SupportDeliverService supportDeliverservice = new SupportDeliverService(); supportDeliverservice = _supportDeliverServiceRepository.FindBy(request.ID); _supportDeliverServiceRepository.Remove(supportDeliverservice); _uow.Commit(); } catch (Exception ex) { response.ErrorMessages.Add(ex.Message); if (ex.InnerException != null) { response.ErrorMessages.Add(ex.InnerException.Message); } } return(response); }
public GeneralResponse AddSeupportDeliverService(AddSupportDeliverServiceRequest request, Guid CreateEmployeeID) { GeneralResponse response = new GeneralResponse(); try { SupportDeliverService supportDeliverService = new SupportDeliverService(); supportDeliverService.ID = Guid.NewGuid(); supportDeliverService.DeliverDate = request.DeliverDate; supportDeliverService.TimeInput = request.TimeInput; supportDeliverService.TimeOutput = request.TimeOutput; supportDeliverService.AmountRecived = request.AmountRecived; supportDeliverService.Comment = request.Comment; supportDeliverService.CreateDate = PersianDateTime.Now; supportDeliverService.CreateEmployee = _employeeRepository.FindBy(CreateEmployeeID); supportDeliverService.RowVersion = 1; supportDeliverService.Support = _supportRepository.FindBy(request.SupportID); #region چک کردن عدم وجود مورد ثبت شده if (supportDeliverService.Support.SupportDeliverService.Count() > 0) { response.ErrorMessages.Add("برای هر پشتیبانی بیش از یک تحویل سرویس نمیتوانید ثبت کنید"); return(response); } #endregion SupportStatusRelation supportStatusRelation = _supportStatusRelationRepository.FindBy(request.SupportStatusID); supportDeliverService.Support.SupportStatus = _supportStatusRepository.FindBy(supportStatusRelation.RelatedSupportStatus.ID); supportDeliverService.Support.Customer.SupportStatus = supportDeliverService.Support.SupportStatus; if (supportDeliverService.Support.SupportStatus.IsLastSupportState) { supportDeliverService.Support.Closed = true; } _supportDeliverServiceRepository.Add(supportDeliverService); #region Send SMS if (supportDeliverService.Support.SupportStatus.SendSmsOnEnter) { // Threading SmsData smsData = new SmsData() { body = supportDeliverService.Support.SupportStatus.SmsText, phoneNumber = supportDeliverService.Support.Customer.Mobile1 }; Thread oThread = new Thread(SendSmsVoid); oThread.Start(smsData); } #endregion _uow.Commit(); } catch (Exception ex) { response.ErrorMessages.Add(ex.Message); if (ex.InnerException != null) { response.ErrorMessages.Add(ex.InnerException.Message); } } return(response); }
public static SupportDeliverServiceView ConvertToSupportDeliverServiceView( this SupportDeliverService supportDeliverService) { return(Mapper.Map <SupportDeliverService, SupportDeliverServiceView>(supportDeliverService)); }