public GetGeneralResponse <SupportPhoneInstallationView> GetSupportPhoneInstallation(Guid SupportID) { GetGeneralResponse <SupportPhoneInstallationView> response = new GetGeneralResponse <SupportPhoneInstallationView>(); try { Query query = new Query(); Criterion SupportIDCriteria = new Criterion("Support.ID", SupportID, CriteriaOperator.Equal); query.Add(SupportIDCriteria); SupportPhoneInstallation supportPhonInstallation = _supportPhoneInstallationRepository.FindBy(query).FirstOrDefault(); response.data = supportPhonInstallation.ConvertToSupportPhoneInstallationView(); 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 AddSupportPhoneInstallation(AddSupportPhoneInstallationRequst request, Guid CreateemployeeID) { GeneralResponse response = new GeneralResponse(); try { SupportPhoneInstallation supportPhoneInstallation = new SupportPhoneInstallation(); supportPhoneInstallation.ID = Guid.NewGuid(); supportPhoneInstallation.CreateDate = PersianDateTime.Now; supportPhoneInstallation.CreateEmployee = _employeeRepository.FindBy(CreateemployeeID); supportPhoneInstallation.Comment = request.Comment; supportPhoneInstallation.InstallDate = request.InstallDate; supportPhoneInstallation.Installed = request.Installed; supportPhoneInstallation.SendNotificationToCustomer = request.SendNotificationToCustomer; supportPhoneInstallation.Support = _supportRepository.FindBy(request.SupportID); supportPhoneInstallation.RowVersion = 1; SupportStatusRelation supportStatusRelation = _supportStatusRelationRepository.FindBy(request.SupportStatusID); supportPhoneInstallation.Support.SupportStatus = _supportStatusRepository.FindBy(supportStatusRelation.RelatedSupportStatus.ID); supportPhoneInstallation.Support.Customer.SupportStatus = supportPhoneInstallation.Support.SupportStatus; if (supportPhoneInstallation.Support.SupportStatus.IsLastSupportState) { supportPhoneInstallation.Support.Closed = true; } _supportPhoneInstallationRepository.Add(supportPhoneInstallation); _uow.Commit(); #region Send SMS if (supportPhoneInstallation.Support.SupportStatus.SendSmsOnEnter) { // Threading SmsData smsData = new SmsData() { body = supportPhoneInstallation.Support.SupportStatus.SmsText, phoneNumber = supportPhoneInstallation.Support.Customer.Mobile1 }; Thread oThread = new Thread(SendSmsVoid); oThread.Start(smsData); } #endregion } catch (Exception ex) { response.ErrorMessages.Add(ex.Message); if (ex.InnerException != null) { response.ErrorMessages.Add(ex.InnerException.Message); } } return(response); }
public GeneralResponse EditSupportPhoneInstalltion(EditSupportPhoneInstallationRequst request, Guid ModifiedEployeeID) { GeneralResponse response = new GeneralResponse(); try { SupportPhoneInstallation supportPhoneInstallation = new SupportPhoneInstallation(); supportPhoneInstallation = _supportPhoneInstallationRepository.FindBy(request.ID); supportPhoneInstallation.Comment = request.Comment; supportPhoneInstallation.ModifiedDate = PersianDateTime.Now; supportPhoneInstallation.ModifiedEmployee = _employeeRepository.FindBy(ModifiedEployeeID); supportPhoneInstallation.InstallDate = request.InstallDate; supportPhoneInstallation.Installed = request.Installed; supportPhoneInstallation.SendNotificationToCustomer = request.SendNotificationToCustomer; #region Row Version Check if (supportPhoneInstallation.RowVersion != request.RowVersion) { response.ErrorMessages.Add("EditConcurrencyKey"); return(response); } else { supportPhoneInstallation.RowVersion += 1; } if (supportPhoneInstallation.GetBrokenRules().Count() > 0) { foreach (BusinessRule businessRule in supportPhoneInstallation.GetBrokenRules()) { response.ErrorMessages.Add(businessRule.Rule); } return(response); } #endregion _supportPhoneInstallationRepository.Save(supportPhoneInstallation); _uow.Commit(); } catch (Exception ex) { response.ErrorMessages.Add(ex.Message); if (ex.InnerException != null) { response.ErrorMessages.Add(ex.InnerException.Message); } } return(response); }
public GeneralResponse DeleteSupportPhonInstallation(DeleteRequest request) { GeneralResponse response = new GeneralResponse(); try { SupportPhoneInstallation supportPhoneInstallation = new SupportPhoneInstallation(); supportPhoneInstallation = _supportPhoneInstallationRepository.FindBy(request.ID); _supportPhoneInstallationRepository.Remove(supportPhoneInstallation); _uow.Commit(); } catch (Exception ex) { response.ErrorMessages.Add(ex.Message); if (ex.InnerException != null) { response.ErrorMessages.Add(ex.InnerException.Message); } } return(response); }
public static SupportPhoneInstallationView ConvertToSupportPhoneInstallationView( this SupportPhoneInstallation supportPhoneInstallation) { return(Mapper.Map <SupportPhoneInstallation, SupportPhoneInstallationView>(supportPhoneInstallation)); }