/// <summary> /// Saves the jurisdiction information. /// </summary> /// <param name="jurisdictionView">The jurisdiction view.</param> /// <returns></returns> /// <exception cref="ArgumentException">AdminSaveJurisdiction</exception> public string SaveJurisdictionInfo(IJurisdictionListView jurisdictionView) { var result = string.Empty; if (jurisdictionView == null) { throw new ArgumentException("AdminSaveJurisdiction"); } var newRecord = new Jurisdiction { IsActive = true, JurisdictionName = jurisdictionView.JurisdictionName, }; try { using ( var dbContext = (PitalyticsEntities)this.dbContextFactory.GetDbContext()) { dbContext.Jurisdictions.Add(newRecord); dbContext.SaveChanges(); } } catch (Exception e) { result = string.Format("SaveJurisdiction - {0} , {1}", e.Message, e.InnerException != null ? e.InnerException.Message : ""); } return(result); }
/// <summary> /// Edits the jurisdiction. /// </summary> /// <param name="jurisdictionView">The jurisdiction view.</param> /// <returns></returns> /// <exception cref="ArgumentNullException"> /// jurisdictionView /// or /// colorDetails /// </exception> public string EditJurisdiction(IJurisdictionListView jurisdictionView) { var result = string.Empty; if (jurisdictionView == null) { throw new ArgumentNullException(nameof(jurisdictionView)); } try { using ( var dbContext = (PitalyticsEntities)this.dbContextFactory.GetDbContext()) { var juridictionDetails = dbContext.Jurisdictions.SingleOrDefault(x => x.JurisdictionId == jurisdictionView.JurisdictionId); if (juridictionDetails == null) { throw new ArgumentNullException(nameof(juridictionDetails)); } juridictionDetails.JurisdictionName = jurisdictionView.JurisdictionName; dbContext.SaveChanges(); } } catch (Exception e) { result = string.Format("EditJurisdiction - {0} , {1}", e.Message, e.InnerException != null ? e.InnerException.Message : ""); } return(result); }
/// <summary> /// Creates the jurisdiction view. /// </summary> /// <param name="jurisdictionView">The jurisdiction view.</param> /// <param name="processingMessage">The processing message.</param> /// <returns></returns> /// <exception cref="ArgumentException">jurisdictionView</exception> public IJurisdictionListView CreateJurisdictionView(IJurisdictionListView jurisdictionView, string processingMessage) { if (jurisdictionView == null) { throw new ArgumentException("jurisdictionView"); } jurisdictionView.ProcessingMessage = processingMessage; return(jurisdictionView); }
/// <summary> /// Processes the color information. /// </summary> /// <param name="jurisdictionView">The jurisdiction view.</param> /// <returns></returns> public string ProcessJurisdictionInfo(IJurisdictionListView jurisdictionView) { var processingMessages = string.Empty; var dataValue = this.generalRepository.GetJurisdictionDescriptionByValue(jurisdictionView.JurisdictionName); if (dataValue != null) { processingMessages = Messages.JurisdictionExist; return(processingMessages); } processingMessages = this.generalRepository.SaveJurisdictionInfo(jurisdictionView); return(processingMessages); }
/// <summary> /// Updates the jurisdiction information. /// </summary> /// <param name="jurisdictionView">The jurisdiction view.</param> /// <returns></returns> /// <exception cref="ArgumentNullException">jurisdictionView</exception> public string UpdateJurisdictionInfo(IJurisdictionListView jurisdictionView) { if (jurisdictionView == null) { throw new ArgumentNullException(nameof(jurisdictionView)); } var processingMessages = string.Empty; var dataValue = this.generalRepository.GetJurisdictionDescriptionByValue(jurisdictionView.JurisdictionName); var isRecordExist = (dataValue == null) ? false : true; if (isRecordExist) { processingMessages = Messages.JurisdictionExist; return(processingMessages); } var editJurisdiction = this.generalRepository.EditJurisdiction(jurisdictionView); return(editJurisdiction); }
/// <summary> /// Gets the jurisdiction view. /// </summary> /// <param name="jurisdictionView">The jurisdiction view.</param> /// <param name="message">The message.</param> /// <returns></returns> public IJurisdictionListView GetJurisdictionView(IJurisdictionListView jurisdictionView, string message) { return(this.generalFactory.CreateJurisdictionView(jurisdictionView, message)); }