public virtual void Update(ErrorBO error) { if (error == null) { throw new ArgumentNullException("error", "Error is null"); } else { db.errorRepository.Edit(error); unitofWork.Commit(); } }
//get all unread #endregion #region Asynchronous Methods public async Task AddAsync(ErrorBO error) { if (error == null) { throw new ArgumentNullException("error", "Error is null"); } else { db.errorRepository.Add(error); await unitofWork.CommitAsync(); } }
public void LogError(Exception ex, string currentUserId) { ErrorBO error = new ErrorBO(); error.Message = ex.Message; error.StackTrace = ex.StackTrace; error.URLAccessed = Request.RawUrl; error.IPAddress = Request.UserHostAddress; error.DateCreated = DateTime.UtcNow; error.Audit = new Entity.Entities.Audit(currentUserId); //AddError }
public virtual void Delete(ErrorBO error, bool purge = false) { if (purge) { db.errorRepository.Delete(error); unitofWork.Commit(); } else { error.Audit.RecordState = Entity.Enums.RecordStateType.InActive; Update(error); } }
/// <summary> /// Saves the Time Entry /// </summary> /// <param name="dataAccessToken"></param> /// <param name="timeEntrySubmissionDetails"></param> /// <returns>TimeEntryListBO</returns> public TimeEntryListBO SaveTimeEntry(string dataAccessToken, string apiVersion, TimeEntrySubmissionBO timeEntrySubmissionDetails) { ErrorBO output = null; TimeEntryListBO outputTimeEntries = new TimeEntryListBO(); try { // Calls the Validations before submitting data output = SubmitValidation(dataAccessToken, apiVersion, timeEntrySubmissionDetails); // If validations pass if (output != null && string.IsNullOrEmpty(output.Message)) { // Call SaveTimeEntry / UpdateTimeEntry of Integration layer based on timeentryId TimeEntryService integrationService = new TimeEntryService(); if (String.IsNullOrEmpty(timeEntrySubmissionDetails.TimeEntryId)) { outputTimeEntries.timeEntries = integrationService.SaveTimeEntry(Constants.CONSUMER_SECRET_TOKEN, UtilityService.DecryptedText(dataAccessToken), apiVersion, timeEntrySubmissionDetails); } else { outputTimeEntries.timeEntries = integrationService.UpdateTimeEntry(Constants.CONSUMER_SECRET_TOKEN, UtilityService.DecryptedText(dataAccessToken), apiVersion, timeEntrySubmissionDetails); } } else { outputTimeEntries.ErrorMessage = output.Message; } } catch (DovicoException e) { logger.Log(LogLevel.Error, e); outputTimeEntries.ErrorMessage = e.Message; } catch (Exception e) { logger.Log(LogLevel.Error, e); outputTimeEntries.ErrorMessage = "Error Saving Time Entry."; } return(outputTimeEntries); }
/// <summary> /// For Validating the time entry before saving /// </summary> /// <param name="dataAccessToken"></param> /// <param name="timeEntrySubmissionDetails"></param> /// <returns>ErrorBO</returns> private ErrorBO SubmitValidation(string dataAccessToken, string apiVersion, TimeEntrySubmissionBO timeEntrySubmissionDetails) { ErrorBO error = new ErrorBO(); try { CustomTerminologyBO customTerminology = GetCustomTerminology(Constants.CONSUMER_SECRET_TOKEN, dataAccessToken, apiVersion); // Validate Clientid, ProjectId, TaskId for required if (customTerminology != null) { if (string.IsNullOrEmpty(timeEntrySubmissionDetails.ClientId)) { error.Message = "Please select" + customTerminology.Client.Singular; return(error); } if (string.IsNullOrEmpty(timeEntrySubmissionDetails.ProjectId)) { error.Message = "Please select" + customTerminology.Project.Singular; return(error); } if (string.IsNullOrEmpty(timeEntrySubmissionDetails.TaskId)) { error.Message = "Please select" + customTerminology.Task.Singular; return(error); } } // Check Description for 4000 lenght if (!string.IsNullOrEmpty(timeEntrySubmissionDetails.Description)) { if (timeEntrySubmissionDetails.Description.Length > 4000) { error.Message = "Description cannot be greater than 4000 Characters."; return(error); } } // Check hours for greater than 0 if (!timeEntrySubmissionDetails.CalendarEntry) { if (timeEntrySubmissionDetails.Hours == 0.0) { error.Message = "Please Enter Total Hours"; return(error); } } // If Calendar entry check start/stop time for required and validity if (timeEntrySubmissionDetails.CalendarEntry) { if (string.IsNullOrEmpty(timeEntrySubmissionDetails.StartTime)) { error.Message = "Please Enter Start Time."; return(error); } if (string.IsNullOrEmpty(timeEntrySubmissionDetails.StopTime)) { error.Message = "Please Enter Stop Time."; return(error); } if (!Utility.IsValidTimeFormat(timeEntrySubmissionDetails.StartTime)) { error.Message = "Please enter valid start time."; return(error); } if (!Utility.IsValidTimeFormat(timeEntrySubmissionDetails.StopTime)) { error.Message = "Please enter valid stop time."; return(error); } if (!Utility.IsValidTime(Convert.ToDateTime(timeEntrySubmissionDetails.StartDate.ToShortDateString() + " " + timeEntrySubmissionDetails.StartTime), Convert.ToDateTime(timeEntrySubmissionDetails.EndDate.ToShortDateString() + " " + timeEntrySubmissionDetails.StopTime))) { error.Message = "Stop Time should be greater than Start Time"; return(error); } } return(error); } catch (Exception e) { logger.Log(LogLevel.Error, e); error.Message = e.Message; return(error); } }