public Result Insert(string sql) { InsertRequest request = new InsertRequest(sql); InsertResponse response = this.Insert(request); return(response.InsertResult); }
public JsonResult SaveVideo(VideoModel video) { var sessionId = this.Session["SessionID"].ToString(); IUserSessionRepository userSessionRepository = RepositoryClassFactory.GetInstance().GetUserSessionRepository(); UserSession userSession = userSessionRepository.FindByID(sessionId); if (userSession == null) { return(Json(new { errorCode = (int)ErrorCode.Redirect, message = Resources.AdminResource.msg_sessionInvalid }, JsonRequestBehavior.AllowGet)); } InsertResponse response = new InsertResponse(); video.Title = video.Title.Length > 200 ? video.Title.Substring(0, 100) + "..." : video.Title; if (!string.IsNullOrEmpty(video.Shortcontent)) { video.Shortcontent = video.Shortcontent.Length > 300 ? video.Shortcontent.Substring(0, 296) + "..." : video.Shortcontent; } else { video.Shortcontent = null; } video.ActionURL = string.Format("{0}-{1}", UrlSlugger.ToUrlSlug(video.Title), UrlSlugger.Get8Digits()); video.CreatedDate = DateTime.Now; video.VideoID = Guid.NewGuid().ToString(); video.CreatedBy = userSession != null ? userSession.UserID : string.Empty; response = _videoService.CreateVideo(video); return(Json(new { errorCode = response.ErrorCode, message = response.Message }, JsonRequestBehavior.AllowGet)); }
public JsonResult SaveImportantDeadline(ImportantDeadlineModel importantDeadline) { var sessionId = this.Session["SessionID"].ToString(); IUserSessionRepository userSessionRepository = RepositoryClassFactory.GetInstance().GetUserSessionRepository(); UserSession userSession = userSessionRepository.FindByID(sessionId); if (userSession == null) { return(Json(new { errorCode = (int)ErrorCode.Redirect, message = Resources.AdminResource.msg_sessionInvalid }, JsonRequestBehavior.AllowGet)); } InsertResponse response = new InsertResponse(); importantDeadline.Title = importantDeadline.Title.Length > 200 ? importantDeadline.Title.Substring(0, 100) + "..." : importantDeadline.Title; if (importantDeadline.ShortContent != null) { importantDeadline.ShortContent = importantDeadline.ShortContent.Length > 300 ? importantDeadline.ShortContent.Substring(0, 296) + "..." : importantDeadline.ShortContent; } importantDeadline.DeadlineID = Guid.NewGuid().ToString(); importantDeadline.ActionURL = string.Format("{0}-{1}", UrlSlugger.ToUrlSlug(importantDeadline.Title), UrlSlugger.Get8Digits()); importantDeadline.CreatedDate = DateTime.Now; importantDeadline.CreatedBy = userSession != null ? userSession.UserID : string.Empty; response = _importantDeadline.CreateImportantDeadline(importantDeadline); return(Json(new { errorCode = response.ErrorCode, message = response.Message }, JsonRequestBehavior.AllowGet)); }
public async Task ExecuteAsync_CallsService() { // Arrange var fakeResult = new Response { InsertResponse = new InsertResponse { Added = true } }; var request = new Request { InsertRequest = new InsertRequest(), Type = RequestType.Insert }; var server = new ServerConfig(); IConnection con = Substitute.For <IConnection>(); con.SendAsync(request, server).Returns(fakeResult); var processor = new FakeProcessor(); // Act InsertResponse response = await processor.ExecuteAsync(request, con, server); // Assert await con.Received(1).SendAsync(request, server); Assert.Equal(fakeResult.InsertResponse, response); }
public JsonResult SaveAlbum(AlbumModel album) { var sessionId = this.Session["SessionID"].ToString(); IUserSessionRepository userSessionRepository = RepositoryClassFactory.GetInstance().GetUserSessionRepository(); UserSession userSession = userSessionRepository.FindByID(sessionId); if (userSession == null) { return(Json(new { errorCode = (int)ErrorCode.Redirect, message = Resources.AdminResource.msg_sessionInvalid }, JsonRequestBehavior.AllowGet)); } InsertResponse response = new InsertResponse(); album.Title = album.Title.Length > 200 ? album.Title.Substring(0, 100) + "..." : album.Title; if (!string.IsNullOrEmpty(album.Description)) { album.Description = album.Description.Length > 300 ? album.Description.Substring(0, 296) + "..." : album.Description; } else { album.Description = null; } album.ActionURL = string.Format("{0}-{1}", UrlSlugger.ToUrlSlug(album.Title), UrlSlugger.Get8Digits()); album.CreatedDate = DateTime.Now; album.AlbumID = Guid.NewGuid().ToString(); album.CreatedBy = userSession != null ? userSession.UserID : string.Empty; response = _albumService.CreateAlbum(album); return(Json(new { errorCode = response.ErrorCode, message = response.Message }, JsonRequestBehavior.AllowGet)); }
public JsonResult UploadFiles(HttpPostedFileBase file) { var sessionId = this.Session["SessionID"].ToString(); IUserSessionRepository userSessionRepository = RepositoryClassFactory.GetInstance().GetUserSessionRepository(); UserSession userSession = userSessionRepository.FindByID(sessionId); if (userSession == null) { return(Json(new { errorCode = (int)ErrorCode.Redirect, message = Resources.AdminResource.msg_sessionInvalid }, JsonRequestBehavior.AllowGet)); } InsertResponse response = new InsertResponse(); string url = string.Empty; string msg = string.Empty; int errorcode = 0; if (file != null) { try { //Create folder try { if (!System.IO.File.Exists(Server.MapPath("~/Content/upload/files/"))) { Directory.CreateDirectory(Server.MapPath("~/Content/upload/files/")); } } catch (Exception) {} string filename = file.FileName.Substring(0, file.FileName.LastIndexOf(".")); filename = string.Format("{0}-{1}", filename, UrlSlugger.Get8Digits()).Replace(" ", "_"); string extension = file.FileName.Substring(file.FileName.LastIndexOf(".")); file.SaveAs(Server.MapPath("~/Content/upload/files/" + filename + extension)); url = string.Format("{0}://{1}:{2}/{3}", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, "Content/upload/files/" + filename + extension); UploadModel upload = new UploadModel(); upload.UploadID = Guid.NewGuid().ToString(); upload.CreatedBy = userSession.UserID; upload.CreatedDate = DateTime.Now; upload.Title = filename; upload.UploadURL = url; upload.FilePath = "/Content/upload/files/" + filename + extension; response = _uploadService.CreateUpload(upload); } catch (Exception ex) { msg = ex.Message; errorcode = (int)ErrorCode.Error; } } return(Json(new { errorcode = errorcode, message = msg, url = url }, JsonRequestBehavior.AllowGet)); }
public ApplicationResult(InsertResponse <TEntity> insertResponse) { var objResult = new { Payload = insertResponse.Payload, }; StatusCodeResponse = insertResponse.StatusCode; ContentResponse = JsonConvert.SerializeObject(objResult, this.GetJsonSettings()); }
private InsertResponse Insert(InsertRequest request) { CFInvokeInfo info = new CFInvokeInfo(); info.Action = "http://tempuri.org/IServiceBase/Insert"; info.RequestIsWrapped = true; info.ReplyAction = "http://tempuri.org/IServiceBase/InsertResponse"; info.ResponseIsWrapped = true; InsertResponse retVal = base.Invoke <InsertRequest, InsertResponse>(info, request); return(retVal); }
public string Insert(string opType, string barCode, System.DateTime scanTime, string userName) { InsertRequest inValue = new InsertRequest(); inValue.opType = opType; inValue.barCode = barCode; inValue.scanTime = scanTime; inValue.userName = userName; InsertResponse retVal = ((IPDAOrder)(this)).Insert(inValue); return(retVal.InsertResult); }
public static async Task <int> Insert(object obj, Type T, Type TPHtype = null) { using var channel = GenerateChannel(); var client = new NetshopClient(channel); InsertResponse res = await client.InsertAsync(RequestHelper(obj, T, TPHtype)); if (res.Error.ErrorResponse != "") { throw new Exception(res.Error.ErrorResponse); } return(res.InsertedID); }
public void Handle_ReturnsTrueWhenElementAdded(bool added) { // arrange var request = new InsertRequest(); var processor = new InsertProcessor(); var storage = Substitute.For <IStorage>(); storage.Add(Arg.Any <string>(), Arg.Any <DateTime?>(), Arg.Any <ByteString>()).Returns(added); // Act InsertResponse response = processor.Reply(request, storage); // assert Assert.Equal(response.Added, added); }
public static async Task <int> PlaceOrder(int partsID, int partsQTY, string clientName, string clientEmail) { using var channel = GenerateChannel(); var client = new NetshopClient(channel); var req = new PlaceOrderRequest { PartsId = partsID, PartsQty = partsQTY, ClientName = clientName, ClientEMail = clientEmail }; InsertResponse res = await client.PlaceOrderAsync(req); if (res.Error.ErrorResponse != "") { throw new Exception(res.Error.ErrorResponse); } return(res.InsertedID); }
public byte[] Insert(byte[] requestData) { object result = null; try { InsertRequest request = (InsertRequest)Deserialize(requestData); IDataAccess dao = DataAccessFactory.Create(request.ObjectType); int state = dao.Insert(request.Object); result = new InsertResponse() { Result = state }; } catch (Exception ex) { result = ex; } return Serialize(result); }
public JsonResult SaveNews(NewsModel news, HttpPostedFileBase imageFile) { var sessionId = this.Session["SessionID"].ToString(); IUserSessionRepository userSessionRepository = RepositoryClassFactory.GetInstance().GetUserSessionRepository(); UserSession userSession = userSessionRepository.FindByID(sessionId); if (userSession == null) { return(Json(new { errorCode = (int)ErrorCode.Redirect, message = Resources.AdminResource.msg_sessionInvalid }, JsonRequestBehavior.AllowGet)); } InsertResponse response = new InsertResponse(); news.Title = news.Title.Length > 200 ? news.Title.Substring(0, 100) + "..." : news.Title; news.ShortContent = news.ShortContent.Length > 300 ? news.ShortContent.Substring(0, 296) + "..." : news.ShortContent; news.ActionURL = string.Format("{0}-{1}", UrlSlugger.ToUrlSlug(news.Title), UrlSlugger.Get8Digits()); news.CreatedDate = DateTime.Now; news.NewsID = Guid.NewGuid().ToString(); news.CreatedBy = userSession != null ? userSession.UserID : string.Empty; response = _newsService.CreateNews(news); if (response.ErrorCode == (int)ErrorCode.None) { //Image if (imageFile != null) { //Create folder try { if (!System.IO.File.Exists(Server.MapPath("~/Content/upload/images/news/"))) { Directory.CreateDirectory(Server.MapPath("~/Content/upload/images/news/")); } } catch (Exception) { } string extension = imageFile.FileName.Substring(imageFile.FileName.LastIndexOf(".")); string filename = imageFile.FileName.Substring(0, imageFile.FileName.LastIndexOf(".")).Replace(" ", "-"); filename = string.Format("{0}-{1}", filename, UrlSlugger.Get8Digits()); imageFile.SaveAs(Server.MapPath("~/Content/upload/images/news/" + filename + extension)); news.ThumbnailURL = "/Content/upload/images/news/" + filename + extension; _newsService.UpdateNews(news); } } return(Json(new { errorCode = response.ErrorCode, message = response.Message }, JsonRequestBehavior.AllowGet)); }
public async Task <InsertResponse> BulkInsertUsersAsync(List <UserModel> users) { var sWatch = new Stopwatch(); sWatch.Start(); await Collection.InsertManyAsync(users); sWatch.Stop(); var response = new InsertResponse { Count = users.Count, ElapsedTime = sWatch.ElapsedMilliseconds.ToString() }; return(response); }
public async Task <InsertResponse> BulkInsertHospitalsAsync(List <Hospital> hospitals) { var sWatch = new Stopwatch(); sWatch.Start(); await Collection.InsertManyAsync(hospitals); sWatch.Stop(); var response = new InsertResponse { Count = hospitals.Count, ElapsedTime = sWatch.ElapsedMilliseconds.ToString() }; return(response); }
public async Task <InsertResponse> Create(List <Patient> items) { var sWatch = new Stopwatch(); sWatch.Start(); db.BulkInsert(items); sWatch.Stop(); var response = new InsertResponse { Count = items.Count, ElapsedTime = sWatch.ElapsedMilliseconds.ToString() }; return(response); }
public async Task <InsertResponse> BulkInsertDrugstoresAsync(List <Drugstore> drugstores) { var sWatch = new Stopwatch(); sWatch.Start(); await Collection.InsertManyAsync(drugstores); sWatch.Stop(); var response = new InsertResponse { Count = drugstores.Count, ElapsedTime = sWatch.ElapsedMilliseconds.ToString() }; return(response); }
public async Task <InsertResponse> BulkInsertContractAsync(List <Contract> contracts) { var sWatch = new Stopwatch(); sWatch.Start(); await Collection.InsertManyAsync(contracts); sWatch.Stop(); var response = new InsertResponse { Count = contracts.Count, ElapsedTime = sWatch.ElapsedMilliseconds.ToString() }; return(response); }
} // Insert public SetByGuidResponse SetByGuid(SetByGuidRequest request) { SetByGuidResponse response = new SetByGuidResponse(); try { IsExistByGuidResponse isExistByGuidResponse = IsExistByGuid(new IsExistByGuidRequest() { Guid = request.Guid }); if (isExistByGuidResponse.Result.Success()) { UpdateByGuidResponse updateByGuidResponse = UpdateByGuid( new UpdateByGuidRequest() { Guid = request.Guid , Ac4yPersistentChild = request.Ac4yPersistentChild }); response.Result = updateByGuidResponse.Result; } else { InsertResponse insertResponse = Insert( new InsertRequest() { Ac4yPersistentChild = request.Ac4yPersistentChild }); response.Result = insertResponse.Result; } } catch (Exception exception) { response.Result = (new Ac4yProcessResult() { Code = Ac4yProcessResult.FAIL, Message = exception.Message, Description = exception.StackTrace }); } return(response); } // SetByGuid
public ActionResult CreateCategoryMenu(MenuModel menu, string parentTitle) { if (ModelState.IsValid) { FindItemReponse <MenuModel> findParentMenu = _menuCategoryService.FindByTitle(parentTitle); if (findParentMenu.Item != null) { menu.ParentID = findParentMenu.Item.MenuID; } menu.MenuID = Guid.NewGuid().ToString(); menu.ActionURL = string.Format("{0}-{1}", UrlSlugger.ToUrlSlug(menu.Title), UrlSlugger.Get8Digits()); menu.CreatedDate = DateTime.Now; InsertResponse response = _menuCategoryService.CreateMenu(menu); } return(RedirectToAction("Index")); }
public JsonResult SavePayment(PaymentModel payment) { var sessionId = this.Session["SessionID"].ToString(); IUserSessionRepository userSessionRepository = RepositoryClassFactory.GetInstance().GetUserSessionRepository(); UserSession userSession = userSessionRepository.FindByID(sessionId); if (userSession == null) { return(Json(new { errorCode = (int)ErrorCode.Redirect, message = Resources.AdminResource.msg_sessionInvalid }, JsonRequestBehavior.AllowGet)); } payment.PaymentID = Guid.NewGuid().ToString(); payment.CreatedBy = userSession.UserID; payment.CreatedDate = DateTime.Now; InsertResponse response = _paymentService.Create(payment); return(Json(new { ErrorCode = response.ErrorCode, Message = response.Message }, JsonRequestBehavior.AllowGet)); }
public JsonResult SaveRole(RoleModel role) { var sessionId = this.Session["SessionID"].ToString(); IUserSessionRepository userSessionRepository = RepositoryClassFactory.GetInstance().GetUserSessionRepository(); UserSession userSession = userSessionRepository.FindByID(sessionId); if (userSession == null) { return(Json(new { errorCode = (int)ErrorCode.Redirect, message = Resources.AdminResource.msg_sessionInvalid }, JsonRequestBehavior.AllowGet)); } role.RoleID = Guid.NewGuid().ToString(); role.CreatedBy = userSession.UserID; role.CreatedDate = DateTime.Now; role.Type = (int)RoleType.Custom; InsertResponse response = _adminService.CreateRole(role); return(Json(new { errorCode = response.ErrorCode, message = response.Message, roleid = response.InsertID, roleName = Enum.GetName(typeof(RoleType), role.Type) }, JsonRequestBehavior.AllowGet)); }
public virtual InsertResponse <TEntity> Insert(InsertRequest <TMessage> request) { var entity = CreateFromMessage(request.Message); var result = _validator.Validate <TEntity>(entity); if (!result.IsValid) { throw new ValidationException(result.Errors); } entity = _repository.Insert(entity); var response = new InsertResponse <TEntity>() { StatusCode = 200, Payload = entity }; return(response); }
public ActionResult RegisterUser(UserModel user) { if (ModelState.IsValid) { InsertResponse response = new InsertResponse(); FindItemReponse <UserModel> usernameResponse = _userService.CheckUsername(user.UserName); if (usernameResponse.Item != null) { response = new InsertResponse { ErrorCode = (int)ErrorCode.Error, Message = Resources.Resource.msg_username_exist }; ViewBag.Response = response; return(View("Register")); } else { FindItemReponse <UserModel> emailResponse = _userService.CheckEmail(user.Email); if (emailResponse.Item != null) { response = new InsertResponse { ErrorCode = (int)ErrorCode.Error, Message = Resources.Resource.msg_email_exist }; ViewBag.Response = response; return(View("Register")); } else { user.UserID = Guid.NewGuid().ToString(); user.CreatedDate = DateTime.Now; response = _userService.CreateUser(user); ViewBag.Response = response; } } } return(View("Register")); }
public InsertResponse Insert(InsertRequest request) { InsertResponse response = new InsertResponse(); try { response.User = new EFUserMethodsCAP().Insert(request.User); response.Result = new Ac4yProcessResult() { Code = Ac4yProcessResult.SUCCESS }; } catch (Exception exception) { response.Result = (new Ac4yProcessResult() { Code = Ac4yProcessResult.FAIL, Message = exception.Message, Description = exception.StackTrace }); } return(response); }
} // UpdateByGuid public InsertResponse Insert(InsertRequest request) { InsertResponse response = new InsertResponse(); try { new Ac4yPersistentChildEFCap().Insert(request.Ac4yPersistentChild); response.Result = new Ac4yProcessResult() { Code = Ac4yProcessResult.SUCCESS }; } catch (Exception exception) { response.Result = (new Ac4yProcessResult() { Code = Ac4yProcessResult.FAIL, Message = exception.Message, Description = exception.StackTrace }); } return(response); } // Insert
public JsonResult AssignAbstractSubmission(string userID, string submissionNumber, int status) { var sessionId = this.Session["SessionID"].ToString(); IUserSessionRepository userSessionRepository = RepositoryClassFactory.GetInstance().GetUserSessionRepository(); UserSession userSession = userSessionRepository.FindByID(sessionId); if (userSession == null) { return(Json(new { errorCode = (int)ErrorCode.Redirect, message = Resources.AdminResource.msg_sessionInvalid }, JsonRequestBehavior.AllowGet)); } UserSubmissionModel model = new UserSubmissionModel(); model.SubmitID = Guid.NewGuid().ToString(); model.CreatedDate = DateTime.Now; model.SubmissionNumber = submissionNumber; model.UserID = userID; model.Status = status; InsertResponse response = _userSubmissionService.Create(model); return(Json(response, JsonRequestBehavior.AllowGet)); }
} // UpdateById /* * public UpdateByGuidResponse UpdateByGuid(UpdateByGuidRequest request) * { * * UpdateByGuidResponse response = new UpdateByGuidResponse(); * * try * { * if (new UserTokenCap().IsExistByGuid(request.Guid)) { * * new UserTokenCap().UpdateByGuid(request.Guid, request.UserToken); * * response.Result = new Ac4yProcessResult() { Code = Ac4yProcessResult.SUCCESS }; * } * else * { * response.Result = new Ac4yProcessResult() { Code = Ac4yProcessResult.FAIL, Message = "Adott id-val nem létezik rekord." }; * } * * } * catch (Exception exception) * { * response.Result = (new Ac4yProcessResult() { Code = Ac4yProcessResult.FAIL, Message = exception.Message, Description = exception.StackTrace }); * } * * return response; * * } // UpdateByGuid */ public InsertResponse Insert(InsertRequest request) { InsertResponse response = new InsertResponse(); try { UserToken responseUserToken = new UserTokenCap().Insert(request.UserToken); response.Result = new Ac4yProcessResult() { Code = Ac4yProcessResult.SUCCESS }; response.UserToken = responseUserToken; } catch (Exception exception) { response.Result = (new Ac4yProcessResult() { Code = Ac4yProcessResult.FAIL, Message = exception.Message, Description = exception.StackTrace }); } return(response); } // Insert
} // UpdateById /* * public UpdateByGuidResponse UpdateByGuid(UpdateByGuidRequest request) * { * * UpdateByGuidResponse response = new UpdateByGuidResponse(); * * try * { * if (new AuthenticationRequestCap().IsExistByGuid(request.Guid)) { * * new AuthenticationRequestCap().UpdateByGuid(request.Guid, request.AuthenticationRequest); * * response.Result = new Ac4yProcessResult() { Code = Ac4yProcessResult.SUCCESS }; * } * else * { * response.Result = new Ac4yProcessResult() { Code = Ac4yProcessResult.FAIL, Message = "Adott id-val nem létezik rekord." }; * } * * } * catch (Exception exception) * { * response.Result = (new Ac4yProcessResult() { Code = Ac4yProcessResult.FAIL, Message = exception.Message, Description = exception.StackTrace }); * } * * return response; * * } // UpdateByGuid */ public InsertResponse Insert(InsertRequest request) { InsertResponse response = new InsertResponse(); try { AuthenticationRequest responseAuthenticationRequest = new AuthenticationRequestCap().Insert(request.AuthenticationRequest); response.Result = new Ac4yProcessResult() { Code = Ac4yProcessResult.SUCCESS }; response.AuthenticationRequest = responseAuthenticationRequest; } catch (Exception exception) { response.Result = (new Ac4yProcessResult() { Code = Ac4yProcessResult.FAIL, Message = exception.Message, Description = exception.StackTrace }); } return(response); } // Insert
public ActionResult PaymentReturn() { string hashvalidateResult = ""; string vpc_TxnResponseCode = "Unknown"; string amount = "Unknown"; string localed = "Unknown"; string command = "Unknown"; string version = "Unknown"; string cardType = "Unknown"; string orderInfo = "Unknown"; string merchantID = "Unknown"; string authorizeID = "Unknown"; string merchTxnRef = "Unknown"; string transactionNo = "Unknown"; string acqResponseCode = "Unknown"; string txnResponseCode = "Unknown"; string message = "Unknown"; string msg = string.Empty; try { // Khoi tao lop thu vien VPCRequest conn = new VPCRequest("http://onepay.vn"); conn.SetSecureSecret(SECURE_SECRET); // Xu ly tham so tra ve va kiem tra chuoi du lieu ma hoa hashvalidateResult = conn.Process3PartyResponse(Request.QueryString); // Lay gia tri tham so tra ve tu cong thanh toan vpc_TxnResponseCode = conn.GetResultField("vpc_TxnResponseCode", "Unknown"); amount = conn.GetResultField("vpc_Amount", "Unknown"); localed = conn.GetResultField("vpc_Locale", "Unknown"); command = conn.GetResultField("vpc_Command", "Unknown"); version = conn.GetResultField("vpc_Version", "Unknown"); cardType = conn.GetResultField("vpc_Card", "Unknown"); orderInfo = conn.GetResultField("vpc_OrderInfo", "Unknown"); merchantID = conn.GetResultField("vpc_Merchant", "Unknown"); authorizeID = conn.GetResultField("vpc_AuthorizeId", "Unknown"); merchTxnRef = conn.GetResultField("vpc_MerchTxnRef", "Unknown"); transactionNo = conn.GetResultField("vpc_TransactionNo", "Unknown"); acqResponseCode = conn.GetResultField("vpc_AcqResponseCode", "Unknown"); txnResponseCode = vpc_TxnResponseCode; message = conn.GetResultField("vpc_Message", "Unknown"); } catch (Exception ex) { msg = "The payment is in-progress, please ask administrator for looking at this!"; Log(merchTxnRef, merchantID, amount, orderInfo, hashvalidateResult, ex.StackTrace); return(View(new InsertResponse { Message = "An error occurs at payment service, please contact administrator!", ErrorCode = (int)ErrorCode.Error })); } //Find user var participantType = ""; long reference = 0; long.TryParse(orderInfo, out reference); var transactionResponse = _transaction.FindByTransactionReference(reference); string userID = ""; string email = ""; if (transactionResponse.Items != null && transactionResponse.Items.Count > 0) { FindItemReponse <UserModel> userResponse = _userService.FindUserByID(transactionResponse.Items.First().UserId); if (userResponse.Item != null) { userID = userResponse.Item.UserID; email = userResponse.Item.Email; FindAllItemReponse <MailingAddressModel> mailingResponse = _mailingService.FindMailingAddressByUser(userResponse.Item.UserID); if (mailingResponse.Items != null) { var mailing = mailingResponse.Items.SingleOrDefault(); if (mailing != null) { participantType = mailing.ParticipantType; } } } } //Save payment PaymentModel payment = new PaymentModel(); payment.PaymentID = Guid.NewGuid().ToString(); payment.UserID = userID; payment.Amount = double.Parse(amount) / 100; payment.CreatedBy = userID; payment.CreatedDate = DateTime.Now; payment.MerchRef = merchTxnRef; payment.PaymentType = participantType; if (string.IsNullOrEmpty(payment.PaymentType)) { payment.PaymentType = "Unknown"; } try { //Validate transaction if (hashvalidateResult == "CORRECTED" && txnResponseCode.Trim() == "0") { //vpc_Result.Text = "Transaction was paid successful"; payment.Status = (int)PaymentStatus.Completed; msg = "Your payment was paid successful!"; //Sending email //USD decimal usd = 0; decimal usdrate = 0; try { usdrate = DataHelper.GetInstance().GetCurrencyRate(FROM_CURRENCY, 22265); usd = decimal.Parse(amount) / usdrate; } catch (Exception) { } string messageBody = DataHelper.GetInstance().BuildInvoicePdfTemplate(payment.PaymentType, merchTxnRef, transactionNo, usd.ToString(), amount, DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss.fff", CultureInfo.InvariantCulture)); string title = string.Format(PAYMENT_TITLE, transactionNo); Task.Run(() => DataHelper.GetInstance().SendEmail(email, title, messageBody)); } else if (hashvalidateResult == "INVALIDATED" && txnResponseCode.Trim() == "0") { //vpc_Result.Text = "Transaction is pending"; payment.Status = (int)PaymentStatus.Pending; msg = "Your payment was in pending status, please contact our administrator!"; } else { //vpc_Result.Text = "Transaction was not paid successful"; payment.Status = (int)PaymentStatus.Error; msg = "The payment was not paid successful, please try again!"; } } catch (Exception ex) { msg = "The payment is in-progress, please ask administrator for looking at this!"; Log(merchTxnRef, merchantID, amount, orderInfo, hashvalidateResult, ex.StackTrace); } InsertResponse _response = _paymentService.Create(payment); _response.Message = msg; // Log info StringBuilder strBuilder = new StringBuilder(); strBuilder.Append(string.Format("Transaction vpc_MerchTxnRef {0}, ", merchTxnRef)); strBuilder.Append(string.Format("Transaction vpc_Merchant {0}, ", merchantID)); strBuilder.Append(string.Format("Transaction vpc_Amount {0}, ", amount)); strBuilder.Append(string.Format("Transaction vpc_OrderInfo {0}, ", orderInfo)); strBuilder.Append(string.Format("Transaction hashvalidateResult {0}, ", hashvalidateResult)); strBuilder.Append(string.Format("Transaction userId {0}, ", userID)); strBuilder.Append(string.Format("Transaction email {0}, ", email)); TransactionHistoryModel transaction = new TransactionHistoryModel { Action = "Payment completed", CreatedDate = DateTime.Now, Log = strBuilder.ToString(), Status = (int)TransactionStatus.Completed, UserId = merchTxnRef, Email = email, TransactionReference = reference }; _transaction.Create(transaction); return(View(_response)); }