/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { CreateBranchResponse response = new CreateBranchResponse(); return(response); }
/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { CreateBranchResponse response = new CreateBranchResponse(); return response; }
public Task Handle(CreateBranchResponse message, IMessageHandlerContext context) { this.Data.BranchName = message.CreatedBranchName; return(context.Send <RequestAddComment>(msg => { msg.UserName = this.Data.UserName; msg.BranchName = this.Data.BranchName; msg.FileName = this.Data.FileName; msg.Content = this.Data.Content; msg.AddedDate = this.Data.AddedDate; msg.UserWebSite = this.Data.UserWebsite; })); }
public CreateBranchResponse CreateBranch(CreateBranchRequest request) { var response = new CreateBranchResponse(); var entity = CommonLogic.SetMapping <CreateBranchRequest, Branch>(request); try { _context.Add(entity); _context.SaveChanges(); response.IsSuccess = true; } catch { throw new Exception(); } return(response); }
/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { CreateBranchResponse response = new CreateBranchResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.TestExpression("branch", targetDepth)) { var unmarshaller = BranchUnmarshaller.Instance; response.Branch = unmarshaller.Unmarshall(context); continue; } } return(response); }
public static CreateBranchResponse Unmarshall(UnmarshallerContext context) { CreateBranchResponse createBranchResponse = new CreateBranchResponse(); createBranchResponse.HttpResponse = context.HttpResponse; createBranchResponse.RequestId = context.StringValue("CreateBranch.RequestId"); createBranchResponse.ErrorCode = context.StringValue("CreateBranch.ErrorCode"); createBranchResponse.Success = context.BooleanValue("CreateBranch.Success"); createBranchResponse.ErrorMessage = context.StringValue("CreateBranch.ErrorMessage"); CreateBranchResponse.CreateBranch_Result result = new CreateBranchResponse.CreateBranch_Result(); result.BranchName = context.StringValue("CreateBranch.Result.BranchName"); result.ProtectedBranch = context.BooleanValue("CreateBranch.Result.ProtectedBranch"); CreateBranchResponse.CreateBranch_Result.CreateBranch_CommitInfo commitInfo = new CreateBranchResponse.CreateBranch_Result.CreateBranch_CommitInfo(); commitInfo.Id = context.StringValue("CreateBranch.Result.CommitInfo.Id"); commitInfo.ShortId = context.StringValue("CreateBranch.Result.CommitInfo.ShortId"); commitInfo.Title = context.StringValue("CreateBranch.Result.CommitInfo.Title"); commitInfo.AuthorName = context.StringValue("CreateBranch.Result.CommitInfo.AuthorName"); commitInfo.AuthorEmail = context.StringValue("CreateBranch.Result.CommitInfo.AuthorEmail"); commitInfo.CreatedAt = context.StringValue("CreateBranch.Result.CommitInfo.CreatedAt"); commitInfo.Message = context.StringValue("CreateBranch.Result.CommitInfo.Message"); commitInfo.AuthorDate = context.StringValue("CreateBranch.Result.CommitInfo.AuthorDate"); commitInfo.CommittedDate = context.StringValue("CreateBranch.Result.CommitInfo.CommittedDate"); commitInfo.CommitterEmail = context.StringValue("CreateBranch.Result.CommitInfo.CommitterEmail"); commitInfo.CommitterName = context.StringValue("CreateBranch.Result.CommitInfo.CommitterName"); List <string> commitInfo_parentIds = new List <string>(); for (int i = 0; i < context.Length("CreateBranch.Result.CommitInfo.ParentIds.Length"); i++) { commitInfo_parentIds.Add(context.StringValue("CreateBranch.Result.CommitInfo.ParentIds[" + i + "]")); } commitInfo.ParentIds = commitInfo_parentIds; result.CommitInfo = commitInfo; createBranchResponse.Result = result; return(createBranchResponse); }
public CreateBranchResponse InsertOrUpdateBranch(InsertOrUpdateBranchRequest request) { var stopwatch = System.Diagnostics.Stopwatch.StartNew(); CreateBranchResponse response = new CreateBranchResponse(); Logger.Info(_logMsg.Clear().SetPrefixMsg("Call BranchService.InsertOrUpdateBranch").ToInputLogString()); Logger.Debug("I:--START--:--BranchService.InsertOrUpdateBranch--"); try { bool valid = false; _commonFacade = new CommonFacade(); if (request.Header != null) { valid = _commonFacade.VerifyServiceRequest <Header>(request.Header); response.Header = new Header { reference_no = request.Header.reference_no, service_name = request.Header.service_name, system_code = request.Header.system_code, transaction_date = request.Header.transaction_date }; } Logger.DebugFormat("-- XMLRequest --\n{0}", request.SerializeObject()); var auditLog = new AuditLogEntity(); auditLog.Module = Constants.Module.WebService; auditLog.Action = Constants.AuditAction.CreateBranch; auditLog.IpAddress = ApplicationHelpers.GetClientIP(); #region == Validate Require Field == if (!valid) { response.StatusResponse = new StatusResponse() { ErrorCode = Constants.ErrorCode.CSMBranch001, Status = Constants.StatusResponse.Failed, Description = "Bad Request, the header is not valid" }; return(response); } else { if (string.IsNullOrEmpty(request.BranchCode)) { return(GetReturnErrorRequireField("BranchCode", response)); } if (string.IsNullOrEmpty(request.BranchName)) { return(GetReturnErrorRequireField("BranchName", response)); } if (string.IsNullOrEmpty(request.ChannelCode)) { return(GetReturnErrorRequireField("ChannelCode", response)); } if (request.StartTimeHour < 0 || request.StartTimeHour > 23) { return(GetReturnErrorInvalidFormat("StartTimeHour", "ต้องมีค่าระหว่าง 0 ถึง 23", "5", response)); } if (request.StartTimeMinute < 0 || request.StartTimeMinute > 59) { return(GetReturnErrorInvalidFormat("StartTimeHour", "ต้องมีค่าระหว่าง 0 ถึง 59", "5", response)); } if (request.EndTimeHour < 0 || request.EndTimeHour > 23) { return(GetReturnErrorInvalidFormat("EndTimeHour", "ต้องมีค่าระหว่าง 0 ถึง 23", "5", response)); } if (request.EndTimeMinute < 0 || request.EndTimeMinute > 59) { return(GetReturnErrorInvalidFormat("EndTimeHour", "ต้องมีค่าระหว่าง 0 ถึง 59", "5", response)); } if (request.Status != 0 && request.Status != 1) { return(GetReturnErrorInvalidFormat("Status", "ต้องมีค่าระหว่าง 0 ถึง 1", "5", response)); } } #endregion #region == Validate Code == var channelDataAccess = new ChannelDataAccess(_context); int?channelId = channelDataAccess.GetChannelIdByChannelCode(request.ChannelCode); if (!channelId.HasValue) { response.StatusResponse = new StatusResponse() { ErrorCode = Constants.ErrorCode.CSMBranch003, Status = Constants.StatusResponse.Failed, Description = "Fail to save branch:\r\nไม่พบ Channel Code ในฐานข้อมูล CSM" }; return(response); } var branchDataAccess = new BranchDataAccess(_context); int?upperBranchId = null; if (!string.IsNullOrEmpty(request.UpperBranchCode)) { upperBranchId = branchDataAccess.GetBranchIdByBranchCode(request.UpperBranchCode); if (!upperBranchId.HasValue) { response.StatusResponse = new StatusResponse() { ErrorCode = Constants.ErrorCode.CSMBranch003, Status = Constants.StatusResponse.Failed, Description = "Fail to save branch:\r\nไม่พบ Upper Branch Code ในฐานข้อมูล CSM" }; return(response); } } #endregion var result = branchDataAccess.InsertOrUpdateBranch(request, channelId.Value, upperBranchId); if (result.IsSuccess) { response.StatusResponse = new StatusResponse { ErrorCode = string.Empty, Status = Constants.StatusResponse.Success, Description = "Save successful" }; AppLog.AuditLog(auditLog, LogStatus.Success, response.StatusResponse.Description); } else { response.StatusResponse = new StatusResponse { ErrorCode = Constants.ErrorCode.CSMBranch003, Status = Constants.StatusResponse.Failed, Description = result.ErrorMessage }; AppLog.AuditLog(auditLog, LogStatus.Fail, response.StatusResponse.Description); } } catch (Exception ex) { Logger.Error("Exception occur:\n", ex); response.StatusResponse = new StatusResponse { ErrorCode = Constants.ErrorCode.CSMBranch004, Status = Constants.StatusResponse.Failed, Description = ex.ToString() }; } finally { Logger.DebugFormat("-- XMLResponse --\n{0}", response.SerializeObject()); stopwatch.Stop(); Logger.DebugFormat("O:--Finish--:ElapsedMilliseconds/{0}", stopwatch.ElapsedMilliseconds); } return(response); }
private static CreateBranchResponse GetReturnErrorInvalidFormat(string fieldName, string errorCode, string remark, CreateBranchResponse response) { response.StatusResponse = new StatusResponse() { ErrorCode = Constants.ErrorCode.CSMBranch002, Status = Constants.StatusResponse.Failed, Description = string.Format("Bad Request, the body is not valid:\r\nไม่สามารถบันทึกรายการได้ เนื่องจากข้อมูลที่ส่งมาอยู่ในรูปแบบไม่ถูกต้อง ({0} {1})", fieldName, remark) }; return(response); }
private static CreateBranchResponse GetReturnErrorRequireField(string fieldName, CreateBranchResponse response) { response.StatusResponse = new StatusResponse() { ErrorCode = Constants.ErrorCode.CSMBranch002, Status = Constants.StatusResponse.Failed, Description = string.Format("Bad Request, the body is not valid:\r\nข้อมูลที่ส่งมาไม่ครบถ้วน ไม่สามารถบันทึกรายการได้ (Field={0})", fieldName) }; return(response); }