public async Task <IActionResult> UpdateContentStatus(SensoryContentStatus contentUpdate) { try { SensoryCheckDataAccess sensoryCheckDataAccess = new SensoryCheckDataAccess(_configuration); DatabaseResponse response = await sensoryCheckDataAccess.UpdateContentStatus(contentUpdate); if (response.ResponseCode == (int)DbReturnValue.Approved) { return(Ok(new OperationResponse { HasSucceeded = true, IsDomainValidationErrors = false, Message = EnumExtensions.GetDescription(DbReturnValue.Approved), ReturnedObject = response.Results })); } else if (response.ResponseCode == (int)DbReturnValue.Rejected) { return(Ok(new OperationResponse { HasSucceeded = true, IsDomainValidationErrors = false, Message = EnumExtensions.GetDescription(DbReturnValue.Rejected), ReturnedObject = response.Results })); } else if (response.ResponseCode == (int)DbReturnValue.ReviewedByOtherUsers) { Log.Error(EnumExtensions.GetDescription(DbReturnValue.ReviewedByOtherUsers)); return(Ok(new OperationResponse { HasSucceeded = false, IsDomainValidationErrors = false, Message = EnumExtensions.GetDescription(DbReturnValue.ReviewedByOtherUsers), ReturnedObject = response.Results })); } else { Log.Error(EnumExtensions.GetDescription(DbReturnValue.ActionAlreadyTaken)); return(Ok(new OperationResponse { HasSucceeded = false, IsDomainValidationErrors = false, Message = EnumExtensions.GetDescription(DbReturnValue.ActionAlreadyTaken) })); } } catch (Exception ex) { Log.Error(new ExceptionHelper().GetLogString(ex, ErrorLevel.Critical)); return(Ok(new OperationResponse { HasSucceeded = false, Message = StatusMessages.ServerError, StatusCode = ((int)ResponseStatus.ServerError).ToString(), IsDomainValidationErrors = false })); } }
public async Task <DatabaseResponse> UpdateContentStatus(SensoryContentStatus contentUpdate) { try { SqlParameter[] parameters = { new SqlParameter("@UserId", SqlDbType.Int), new SqlParameter("@ContentId", SqlDbType.Int), new SqlParameter("@ContentType", SqlDbType.Int), new SqlParameter("@Status", SqlDbType.Bit), new SqlParameter("@Comments", SqlDbType.VarChar) }; parameters[0].Value = contentUpdate.UserId; parameters[1].Value = contentUpdate.ContentId; parameters[2].Value = contentUpdate.ContentType; parameters[3].Value = contentUpdate.Status; parameters[4].Value = contentUpdate.comments; _DataHelper = new DataAccessHelper("spi_SensoryApproveReject ", parameters, _configuration); DataTable dt = new DataTable(); int result = await _DataHelper.RunAsync(dt); int PortalLanguageId = Convert.ToInt32(dt.Rows[0]["PortalLanguageId"]); string text = string.Empty; string buttonText = string.Empty; if (result == (int)DbReturnValue.Rejected) { UserEmail userEmail = new UserEmail(); userEmail.Email = Convert.ToString(dt.Rows[0]["Email"]); if (PortalLanguageId == 2) { text = "Your Content has been rejected during sensitivity check. Click below button to view. <br/>Reason : " + contentUpdate.comments; buttonText = "View Content"; userEmail.Subject = "Content has been rejected"; } else { text = "بعد المراجعة، تم رفض المحتوى المقدم من قبلك.يمكنك الضغط على الرابط أدناه لعرض المحتوى.<br><br>الأسباب:" + contentUpdate.comments + " <br/>"; buttonText = "عرض المحتوى"; userEmail.Subject = "تم رفض المحتوى"; } userEmail.Body = Emailer.CreateEmailBody(Convert.ToString(dt.Rows[0]["UserName"]), contentUpdate.EmailUrl, text, buttonText, Convert.ToInt32(dt.Rows[0]["PortalLanguageId"]), _configuration); await Emailer.SendEmailAsync(userEmail, _configuration); } else if (result == (int)DbReturnValue.Approved) { UserEmail userEmail = new UserEmail(); userEmail.Email = Convert.ToString(dt.Rows[0]["Email"]); if (PortalLanguageId == 2) { text = "Your Content has been approved during sensitivity check. "; buttonText = "View Content"; userEmail.Subject = "Content has been approved"; } else { text = "تم نشر المصدر المحتوى الخاص بك، يمكنك الضغط على الرابط أدناه للعرض. "; buttonText = "عرض المحتوى"; userEmail.Subject = "تم نشر المحتوى ."; } userEmail.Body = Emailer.CreateEmailBody(Convert.ToString(dt.Rows[0]["UserName"]), contentUpdate.EmailUrl, text, buttonText, Convert.ToInt32(dt.Rows[0]["PortalLanguageId"]), _configuration); await Emailer.SendEmailAsync(userEmail, _configuration); } return(new DatabaseResponse { ResponseCode = result, Results = null }); } catch (Exception ex) { Log.Error(new ExceptionHelper().GetLogString(ex, ErrorLevel.Critical)); throw; } finally { _DataHelper.Dispose(); } }