private string jsonErrorMessage(string webSocket, string errorCode, string message, ErrorSeverity severity, string label = "", bool sendMessage = true) { try { #region Create Errorobject ErrorObject error = new ErrorObject { Id = SemafoneConnection.GetNextResponseId(), Datetime = DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss.fff"), ErrorSeverity = severity.ToString(), ErrorLabel = label, ErrorCode = Convert.ToInt32(errorCode), ErrorMessage = message }; ErrorResponse errorResponseMessage = new ErrorResponse(error); #endregion string errorJson = JsonConvert.SerializeObject(errorResponseMessage); TpsLogManager <Semafone> .Error(message + " error message sent to " + webSocket); return(errorJson); } catch (Exception e) { TpsLogManager <Semafone> .Error("Error jsonErrorMessage : " + e.Message + e.StackTrace); return(e.Message); } }
/// <summary> /// Update Users Information /// </summary> /// <param name="data">Users Information</param> /// <returns>Number Affected Row</returns> public static Tuple <ErrorObject, string> Users(tblUser data) { erros = new ErrorObject(); try { using (HSCMEntities db = new HSCMEntities()) { var row = db.tblUser.Single(p => p.id == data.id); if (!String.IsNullOrEmpty(data.password)) { row.password = data.password; } row.user = data.user; row.upDateDate = DateTime.Now; result = db.SaveChanges(); Message = "Affected Row: " + result.ToString(); erros.Error = false; return(new Tuple <ErrorObject, string>(erros.IfError(false), Message)); } } catch (Exception ex) { erros.InfoError(ex); return(new Tuple <ErrorObject, string>(erros, String.Empty)); } }
public static Tuple <ErrorObject, int> GetTotalAmountToTransaction(int AnchorTransactionID, int TransactionTypeID) { int data = 0; erros = new ErrorObject(); try { using (HSCMEntities db = new HSCMEntities()) { data = (from TC in db.tblTransactionConfigurate join T in db.tblTransaction on TC.idTransaction equals T.id where TC.idAnchorTransaction == AnchorTransactionID && TC.idTransactionType == TransactionTypeID select T.amount ).Sum(T => (int)T.Value); } erros.Error = false; return(new Tuple <ErrorObject, int>(erros.IfError(false), data)); } catch (Exception ex) { erros.InfoError(ex); return(new Tuple <ErrorObject, int>(erros, data)); } }
/// <summary> /// Insert TransactionConfigurate Information /// </summary> /// <param name="data">TransactionConfigurate Information</param> /// <returns>Number Affected Row</returns> public static Tuple <ErrorObject, string> TransactionConfigurate(tblTransactionConfigurate data) { erros = new ErrorObject(); try { using (HSCMEntities db = new HSCMEntities()) { int propertyFind = db.tblTransactionConfigurate.Count(); if (propertyFind > 0) { data.id = db.tblTransactionConfigurate.Max(s => s.id); } else { data.id = 1; } db.tblTransactionConfigurate.Add(data); result = db.SaveChanges(); Message = "Affected Row: " + result.ToString(); return(new Tuple <ErrorObject, string>(erros.IfError(false), Message)); } } catch (Exception ex) { erros.InfoError(ex); return(new Tuple <ErrorObject, string>(erros, String.Empty)); } }
/// <summary> /// Insert TransactionType Information /// </summary> /// <param name="data">Transaction Information</param> /// <returns>Number Affected Row</returns> public static Tuple <ErrorObject, int> Transaction(tblTransaction data) { erros = new ErrorObject(); try { using (HSCMEntities db = new HSCMEntities()) { int propertyFind = db.tblTransaction.Count(); if (propertyFind > 0) { data.id = db.tblTransaction.Max(s => s.id); } else { data.id = 1; } db.tblTransaction.Add(data); result = db.SaveChanges(); Message = "Affected Row: " + result.ToString(); if (result > 0) { return(new Tuple <ErrorObject, int>(erros.IfError(false), data.id)); } else { return(new Tuple <ErrorObject, int>(erros.IfError(false), result)); } } } catch (Exception ex) { erros.InfoError(ex); return(new Tuple <ErrorObject, int>(erros, 0)); } }
public ErrorObject GetErrorsObject() { var res = new ErrorObject(); res.Errors = GetErrors(); return(res); }
public void GetTextRuleTestMethod() { ErrorObject err = new ErrorObject(); var rst = ibaserules.GetText(out err, new Text()); Assert.AreEqual(true, rst != null && rst.GetEnumerator().MoveNext()); }
/// <summary> /// Insert Users Information /// </summary> /// <param name="data">Users Information</param> /// <returns>Number Affected Row</returns> public static Tuple <ErrorObject, string> Users(tblUser data) { erros = new ErrorObject(); try { using (EileenGaldamezEntities db = new EileenGaldamezEntities()) { int propertyFind = db.tblUser.Count(); if (propertyFind > 0) { data.id = db.tblUser.Max(s => s.id); } else { data.id = 1; } db.tblUser.Add(data); result = db.SaveChanges(); Message = "Affected Row: " + result.ToString(); return(new Tuple <ErrorObject, string>(erros.IfError(false), Message)); } } catch (Exception ex) { erros.InfoError(ex); return(new Tuple <ErrorObject, string>(erros, String.Empty)); } }
public async Task <IActionResult> DeleteOneProfile([FromRoute] Guid id) { var profileToDelete = await _profileRepository.GetFirstByExpressionAsync(x => x.Id == id); if (profileToDelete == null) { var err = new ErrorObject() { Method = "DELETE", At = $"/api/profiles/{id}", StatusCode = 404, Error = "Could not find profile to delete" }; return(NotFound(err)); } _profileRepository.Delete(profileToDelete); if (!await _profileRepository.SaveAsync()) { var errMsg = "Error deleting a profile"; _logger.Error(errMsg); var err = new ErrorObject() { Method = "DELETE", At = $"/api/profiles/{id}", StatusCode = 500, Error = errMsg }; return(StatusCode(500, err)); } return(NoContent()); }
/// <summary> /// Initializes transaction context. /// </summary> /// <param name="HostAddress">Payflow Host Address.</param> /// <param name="HostPort">Payflow Host Port.</param> /// <param name="TimeOut">Transaction timeout.</param> /// <param name="ProxyAddress">Proxy Address.</param> /// <param name="ProxyPort">Proxy Port.</param> /// <param name="ProxyLogon">Proxy Logon Id.</param> /// <param name="ProxyPassword">Proxy Password.</param> /// <param name="ClientInfo">Client Info</param> public void InitializeContext(String HostAddress, int HostPort, int TimeOut, String ProxyAddress, int ProxyPort, String ProxyLogon, String ProxyPassword, ClientInfo ClientInfo) { Logger.Instance.Log("PayPal.Payments.Communication.PaymentStateMachine.InitializeContext(String, int, int, String, int, String, String): Entered.", PayflowConstants.SEVERITY_DEBUG); try { this.mConnection.InitializeConnection(HostAddress, HostPort, TimeOut, ProxyAddress, ProxyPort, ProxyLogon, ProxyPassword); if (ClientInfo != null) { mClientInfo = ClientInfo; } else { mClientInfo = new ClientInfo(); } this.SetVersionTracking(); this.mConnection.ClientInfo = mClientInfo; } catch (Exception Ex) { ErrorObject Err = PayflowUtility.PopulateCommError(PayflowConstants.E_EMPTY_PARAM_LIST, Ex, PayflowConstants.SEVERITY_ERROR, mPaymentState.IsXmlPayRequest, null); if (!PsmContext.IsCommunicationErrorContained(Err)) { PsmContext.AddError(Err); } } finally { Logger.Instance.Log("PayPal.Payments.Communication.PaymentStateMachine.InitializeContext(String,int,int,String, nt,String,String): Exiting.", PayflowConstants.SEVERITY_DEBUG); } }
/// <summary> /// Insert Assignment Information /// </summary> /// <param name="data">Assignment Information</param> /// <returns>Number Affected Row</returns> public static Tuple <ErrorObject, int> Download(tblDownloadAssignment data) { erros = new ErrorObject(); try { using (EileenGaldamezEntities db = new EileenGaldamezEntities()) { int propertyFind = db.tblDownloadAssignment.Count(); if (propertyFind > 0) { data.id = db.tblDownloadAssignment.Max(s => s.id); } else { data.id = 1; } db.tblDownloadAssignment.Add(data); result = db.SaveChanges(); Message = "Affected Row: " + result.ToString(); return(new Tuple <ErrorObject, int>(erros.IfError(false), data.id)); } } catch (Exception ex) { erros.InfoError(ex); return(new Tuple <ErrorObject, int>(erros, 0)); } }
public IActionResult DeleteAttributesConstraint([FromQuery] int Id) { ErrorObject response = new ErrorObject(); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } int code = _attributeRepository.DeleteAttributesConstraint(Id); if (code == 1) { return(StatusCode(200)); } else if (code == 0) { response.title = AttributeConstant.titleConstraintDelete; response.entityName = AttributeConstant.entityNameConsatraint; response.errorKey = AttributeConstant.errorKeyConstraintDelete; response.status = AttributeConstant.statusError; response.message = AttributeConstant.MessageConstraintDelete; return(StatusCode(400, response)); } else { return(StatusCode(400)); } }
/// <summary> /// Constructor /// </summary> /// <param name="Connection">PaymentConnection Object</param> /// <param name="ParamList">Parameter List</param> /// <param name="PsmContext">Context Object by ref</param> /// <remarks>This is an abstract class, creating an object of PaymentState directly is not possible.</remarks> public PaymentState(PaymentConnection Connection, String ParamList, ref Context PsmContext) : this() { Logger.Instance.Log("PayPal.Payments.Communication.PaymentState.PaymentState(PaymentConnection,String,Context): Entered.", PayflowConstants.SEVERITY_DEBUG); mContext = PsmContext; mConnection = Connection; InitializeContentType(ParamList); if (mContext.HighestErrorLvl < PayflowConstants.SEVERITY_FATAL) { mConnection.ContentType = mContentType; if (ParamList == null || ParamList.Length == 0) { ErrorObject Err = PayflowUtility.PopulateCommError(PayflowConstants.E_EMPTY_PARAM_LIST, null, PayflowConstants.SEVERITY_FATAL, IsXmlPayRequest, null); mContext.AddError(Err); } this.mTransactionRequest = ParamList; ValidateRequestId(); } Logger.Instance.Log("PayPal.Payments.Communication.PaymentState.PaymentState(PaymentConnection,String,Context): Exiting.", PayflowConstants.SEVERITY_DEBUG); }
/// <summary> /// Return All Product By Specific Cellar Area ID /// </summary> /// <param name="CellarAreaID">CellarAreaID</param> /// <returns>All Product</returns> public static Tuple <ErrorObject, List <tblProduct> > GetProductToCellarArea(int CellarAreaID) { List <tblProduct> data = new List <tblProduct>(); List <int> ids = new List <int>(); erros = new ErrorObject(); try { using (EileenGaldamezEntities db = new EileenGaldamezEntities()) { //ids = (from C in db.tblCellar where C.idcellarArea == CellarAreaID select (int)C.idProduct).ToList(); //data = db.tblProduct.ToList(); //for (int v = 0; v < ids.Count; v++) //{ // var itemToRemove = data.SingleOrDefault(r => r.id == ids[v]); // if (itemToRemove != null) // data.Remove(itemToRemove); //} data = db.SP_Product_SelectProduct("GetProductToCellarArea", CellarAreaID, 0, 0).ToList(); }; return(new Tuple <ErrorObject, List <tblProduct> >(erros.IfError(false), data)); } catch (Exception ex) { erros.InfoError(ex); return(new Tuple <ErrorObject, List <tblProduct> >(erros, data)); } }
/// <summary> /// Update Product Information /// </summary> /// <param name="data">Product Information</param> /// <returns>Number Affected Row</returns> public static Tuple <ErrorObject, string> product(tblProduct data) { erros = new ErrorObject(); try { using (EileenGaldamezEntities db = new EileenGaldamezEntities()) { var row = db.tblProduct.Single(p => p.id == data.id); row.name = data.name; row.code = data.code; row.unit = data.unit; row.idProductType = data.idProductType; row.detail = data.detail; row.upDateDate = data.upDateDate; result = db.SaveChanges(); Message = "Affected Row: " + result.ToString(); return(new Tuple <ErrorObject, string>(erros.IfError(false), Message)); } } catch (Exception ex) { erros.InfoError(ex); return(new Tuple <ErrorObject, string>(erros, String.Empty)); } }
/// <summary> /// Initializes Connection Host Attributes. /// </summary> /// <param name="HostAddress">String Value of Host Address.</param> /// <param name="HostPort">Host port as positive integer.</param> /// <param name="TimeOut">Connection Timeout in Seconds.</param> private void InitializeHost(String HostAddress, int HostPort, int TimeOut) { Logger.Instance.Log("PayPal.Payments.Communication.PaymentConnection.InitializeHost(String,int,int): Entered.", PayflowConstants.SEVERITY_DEBUG); if (HostAddress != null && HostAddress.Length > 0) { mHostAddress = HostAddress; Logger.Instance.Log("PayPal.Payments.Communication.PaymentConnection.InitializeHost(String,int,int): HostAddress = " + mHostAddress, PayflowConstants.SEVERITY_INFO); } else { ErrorObject NullHostError = PayflowUtility.PopulateCommError(PayflowConstants.E_NULL_HOST_STRING, null, PayflowConstants.SEVERITY_FATAL, IsXmlPayRequest, null); if (!ConnContext.IsCommunicationErrorContained(NullHostError)) { ConnContext.AddError(NullHostError); } } mHostPort = HostPort; Logger.Instance.Log("PayPal.Payments.Communication.PaymentConnection.InitializeHost(String,int,int): HostPort = " + mHostPort.ToString(), PayflowConstants.SEVERITY_INFO); mConnectionTimeOut = TimeOut; Logger.Instance.Log("PayPal.Payments.Communication.PaymentConnection.InitializeHost(String,int,int): Exiting.", PayflowConstants.SEVERITY_DEBUG); }
public async Task Cannot_filter_equality_on_incompatible_value() { // Arrange var resource = new FilterableResource { SomeInt32 = 1 }; await _testContext.RunOnDatabaseAsync(async dbContext => { await dbContext.ClearTableAsync <FilterableResource>(); dbContext.FilterableResources.AddRange(resource, new FilterableResource()); await dbContext.SaveChangesAsync(); }); const string route = "/filterableResources?filter=equals(someInt32,'ABC')"; // Act (HttpResponseMessage httpResponse, Document responseDocument) = await _testContext.ExecuteGetAsync <Document>(route); // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); responseDocument.Errors.ShouldHaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("Query creation failed due to incompatible types."); error.Detail.Should().Be("Failed to convert 'ABC' of type 'String' to type 'Int32'."); error.Source.Should().BeNull(); }
/// <summary> /// Initialized Transaction. /// </summary> /// <param name="ParamList">Parameter List</param> /// <param name="RequestId">Request Id</param> public void InitTrans(String ParamList, String RequestId) { Logger.Instance.Log("PayPal.Payments.Communication.PaymentStateMachine.InitTrans(String): Entered.", PayflowConstants.SEVERITY_DEBUG); try { this.mConnection.RequestId = RequestId; this.mPaymentState = new SendInitState(this.mConnection, ParamList, ref psmContext); } catch (Exception Ex) { ErrorObject Err = PayflowUtility.PopulateCommError(PayflowConstants.E_CONTXT_INIT_FAILED, Ex, PayflowConstants.SEVERITY_ERROR, mPaymentState.IsXmlPayRequest, null); if (!PsmContext.IsCommunicationErrorContained(Err)) { PsmContext.AddError(Err); } } finally { Logger.Instance.Log("PayPal.Payments.Communication.PaymentStateMachine.InitTrans(String): Exiting.", PayflowConstants.SEVERITY_DEBUG); } }
/// <summary> /// Return All Assingnment To specific Product, category, Codition and TransactionType IDS /// </summary> /// <param name="ProductID"></param> /// <param name="CategoryID"></param> /// <param name="ConditionID"></param> /// <param name="TransactionTypeID"></param> /// <returns>All Assignment</returns> public static Tuple <ErrorObject, tblAssignment> GetAssignmentByProductIDAndCategoryWithCondition(int ProductID, int CategoryID, int ConditionID, int TransactionTypeID) { tblAssignment data = new tblAssignment(); erros = new ErrorObject(); try { using (EileenGaldamezEntities db = new EileenGaldamezEntities()) { data = (from TC in db.tblTransactionConfigurate join A in db.tblAssignment on TC.idAnchorTransaction equals A.id join T in db.tblTransaction on TC.idTransaction equals T.id where A.idProduct == ProductID && TC.idTransactionType == TransactionTypeID && T.idConditionProduct == ConditionID select A).First(); } erros.Error = false; return(new Tuple <ErrorObject, tblAssignment>(erros.IfError(false), data)); } catch (Exception ex) { erros.InfoError(ex); return(new Tuple <ErrorObject, tblAssignment>(erros, data)); } }
public async Task <IActionResult> CreateOneProfile([FromBody] NewProfileDto createdProfile) { var profileToAdd = _mapper.Map <Data.Models.Profile>(createdProfile); profileToAdd.Id = Guid.NewGuid(); var userId = User.Claims.FirstOrDefault(x => x.Type == "userId").Value; profileToAdd.UserId = Guid.Parse(userId); profileToAdd.CreatedOn = DateTime.Now; _profileRepository.Create(profileToAdd); if (!await _profileRepository.SaveAsync()) { var errMsg = "Error creating a profile"; _logger.Error(errMsg); var err = new ErrorObject() { Method = "POST", At = "/api/profiles", StatusCode = 500, Error = errMsg }; return(StatusCode(500, err)); } return(CreatedAtAction(nameof(GetOneProfile), new { id = profileToAdd.Id }, profileToAdd)); }
/// <summary> /// Insert FileManager /// </summary> /// <param name="data">FileManger Information</param> /// <returns></returns> public static Tuple <ErrorObject, int> FileManager(tblFileManager data) { erros = new ErrorObject(); try { using (EileenGaldamezEntities db = new EileenGaldamezEntities()) { int propertyFind = db.tblFileManager.Count(); if (propertyFind > 0) { data.id = db.tblFileManager.Max(s => s.id); } else { data.id = 1; } db.tblFileManager.Add(data); result = db.SaveChanges(); if (result > 0) { return(new Tuple <ErrorObject, int>(erros.IfError(false), data.id)); } else { return(new Tuple <ErrorObject, int>(erros.IfError(false), result)); } } } catch (Exception ex) { erros.InfoError(ex); return(new Tuple <ErrorObject, int>(erros, 0)); } }
public static Tuple <ErrorObject, List <tblUser> > GetUserButConfigurationList() { List <tblUser> Users = new List <tblUser>(); erros = new ErrorObject(); try { using (HSCMEntities db = new HSCMEntities()) { Users = (from U in db.tblUser join UC in db.tblUserConfiguration on U.id equals UC.idUser select U ).ToList(); }; return(new Tuple <ErrorObject, List <tblUser> >(erros.IfError(false), Users)); } catch (Exception ex) { erros.InfoError(ex); return(new Tuple <ErrorObject, List <tblUser> >(erros, Users)); } }
protected IActionResult Error_Bus(int code = 500, string propertyKey = "exception", string errorMessage = "") { var errors = new Dictionary <string, List <string> >(); if (!string.IsNullOrEmpty(errorMessage) && !string.IsNullOrEmpty(propertyKey)) { var errorsList = new List <string>() { errorMessage }; errors.Add(propertyKey, errorsList); } foreach (var item in ModelState) { var errorMessages = item.Value.Errors.Select(x => x.ErrorMessage); var validErrorMessages = new List <string>(); validErrorMessages.AddRange(errorMessages.Where(message => !string.IsNullOrEmpty(message))); if (validErrorMessages.Count > 0) { if (errors.ContainsKey(item.Key)) { errors[item.Key].AddRange(validErrorMessages); } else { errors.Add(item.Key, validErrorMessages.ToList()); } } } StringBuilder builder = new StringBuilder(); foreach (KeyValuePair <string, List <string> > pair in errors) { builder.Append(pair.Key).Append(":").Append(string.Join("|", pair.Value)).Append(','); } string errorResult = builder.ToString(); // Remove the final delimiter errorResult = errorResult.TrimEnd(','); var errorsRootObject = new ErrorObject { Message = errorResult, Code = code }; var errorsJson = JsonHelper.ToJson(errorsRootObject); var group = DateTime.Now.ToString("yyyyMMddHHmm"); IoC.Resolve <IPackStore <TimeData> >().AddQueue(new TimeData(group, MonitorContextKeys.fault, 1)); throw new Exception(errorsJson); }
public IActionResult DoesNetworkExist([FromForm] string guid, [FromForm] string sharedid, [FromForm] string username) { if (!Helper.IsCallerValid(guid, sharedid, _connstrWallet)) { ErrorObject ro = new ErrorObject(); ro.message = "ErrInvalid"; ro.error = true; return(Json(ro)); } bool networkExists = false; string errorMessage = ""; bool isError = false; NpgsqlConnection conn = new NpgsqlConnection(_connstrWallet); conn.Open(); try { NpgsqlCommand com = new NpgsqlCommand("sp_doesnetworkexist", conn); com.CommandType = CommandType.StoredProcedure; com.Parameters.Add(new NpgsqlParameter("p_guid", guid)); com.Parameters.Add(new NpgsqlParameter("p_username", username)); NpgsqlDataReader reader = com.ExecuteReader(CommandBehavior.SingleResult); if (reader.HasRows) { networkExists = true; } else { networkExists = false; } reader.Dispose(); } catch (Exception ex) { isError = true; errorMessage = "ErrSystem"; } finally { conn.Close(); } if (isError) { ErrorObject ro = new ErrorObject(); ro.message = "ErrInvalid"; ro.error = true; return(Json(ro)); } else { NetworkExists ne = new NetworkExists(); ne.message = networkExists; return(Json(ne)); } }
public IActionResult AddVOCProcess([FromBody] ObjectVOCProccess model) { ErrorObject errorObject = new ErrorObject(); FieldErrors error = new FieldErrors(); ResponseMessage rm = new ResponseMessage(); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (model != null) { List <FieldErrors> lsterror = ValidateAddOrEdit(model); if (lsterror.Count > 0) { // response validate fail to client rm.Type = VOCProcessConstant.TypeVOC; rm.Title = VOCProcessConstant.TitleValidate; rm.Message = VOCProcessConstant.ErrorValidate; rm.Status = VOCProcessConstant.StatusFail; var field = new { fieldErrors = lsterror }; rm.FieldError = field; return(StatusCode(400, rm)); } else { ErrorObject response = new ErrorObject(); // thêm vào database int result = _iVOCProcessRepository.AddVOCProcess(model, userName); if (result == VOCProcessConstant.AddDuplicateCode) { response.EntityName = VOCProcessConstant.TypeVOC; response.ErrorKey = VOCProcessConstant.ErrorKeyAddDuplicateCode; response.Status = VOCProcessConstant.StatusFail; response.Message = VOCProcessConstant.MessageAddDuplicateCode; return(StatusCode(400, response)); } else if (result == VOCProcessConstant.AddVOCProcessSuccess) { object obj = new { message = VOCProcessConstant.MessageAddSuccess }; return(StatusCode(201, obj)); } else { response = new ErrorObject(); response.EntityName = VOCProcessConstant.TypeVOC; response.ErrorKey = VOCProcessConstant.ErrorKeyAddFail; response.Status = VOCProcessConstant.StatusFail; response.Message = VOCProcessConstant.MessageAddFail; return(StatusCode(400, response)); } } } else { return(BadRequest()); } }
public void ValidateBookings_SamefromDateDifferentTodate_FromTimeEqualsInitialBookingToTime_ReturnsFalse() { LoadListBooking(); ErrorObject result = ValidateBookng.IsValid(list_booking, "1", "02/09/2019", "02/10/2019", "11:00", "12:00"); Assert.IsFalse(result.GetIsValid()); }
public void ValidateBookings_FromTimeMoreThanToDate_ReturnsFalse() { LoadListBooking(); ErrorObject result = ValidateBookng.IsValid(list_booking, "1", "02/09/2019", "02/09/2019", "11:00", "10:00"); Assert.IsFalse(result.GetIsValid()); }
public void ValidateBookings_SameDayDifferentTime_ReturnsTrue() { LoadListBooking(); ErrorObject result = ValidateBookng.IsValid(list_booking, "1", "02/09/2019", "02/09/2019", "11:30", "12:00"); Assert.IsTrue(result.GetIsValid()); }
public override string ToString() { var msg = CatchedException.Message; msg += $"{Environment.NewLine}{ErrorObject.ToString()}"; return(msg); }
public object AddCategory([FromBody] CategoryChildren tblCategory) { ErrorObject response = new ErrorObject(); ResponseMessage rm = new ResponseMessage(); FieldErrors error = new FieldErrors(); object objCate = new TblCategory(); string userName = User.Claims.FirstOrDefault().Value; tblCategory.CreateBy = userName; if (string.IsNullOrEmpty(tblCategory.CategoryName)) { List <FieldErrors> lsterror = new List <FieldErrors>(); if (string.IsNullOrEmpty(tblCategory.CategoryName)) { error.objectName = CategoryConstant.TypeCategory; error.field = CategoryConstant.entityName; error.message = CategoryConstant.Message; lsterror.Add(error); } rm.Title = CategoryConstant.Title; rm.Message = CategoryConstant.MessageError; rm.Status = CategoryConstant.statusError; var field = new { fieldErrors = lsterror }; rm.fieldError = field; return(StatusCode(400, rm)); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } object objCategory = _categoryRepository.AddCategory(tblCategory); int code = Convert.ToInt32(objCategory.GetType().GetProperty(CategoryConstant.Code).GetValue(objCategory, null)); string CateCode = objCategory.GetType().GetProperty(CategoryConstant.CategoryCode).GetValue(objCategory, null).ToString(); if (code == 0) { response.title = CategoryConstant.titleDuplicate; response.entityName = CategoryConstant.entityName; response.errorKey = CategoryConstant.errorKey; response.status = CategoryConstant.statusError; response.message = CategoryConstant.MessageDulicateCategoryName; return(StatusCode(400, response)); } else if (code == 1) { if (!string.IsNullOrEmpty(CateCode)) { objCate = _categoryRepository.GetObjectCategory(CateCode); } var responeNew = new { TblCategory = objCate }; return(StatusCode(201, responeNew)); } else { return(StatusCode(400)); } }
public static System.Exception ToException(ErrorObject err) {}
// Methods public static System.Exception op_Explicit(ErrorObject err) {}