protected void Load_PaymentType() { List <PaymentType> paymentTypeList = PaymentTypeController.getAllPaymentType(); for (int i = 0; i < paymentTypeList.Count; i++) { TableRow newRow = new TableRow(); PaymentTypeTable.Controls.Add(newRow); TableCell numberCell = new TableCell(); numberCell.Controls.Add(new Label() { Text = (i + 1) + "." }); newRow.Cells.Add(numberCell); TableCell paymentTypeIDCell = new TableCell(); paymentTypeIDCell.Controls.Add(new Label() { Text = paymentTypeList.ElementAt(i).ID.ToString() }); newRow.Cells.Add(paymentTypeIDCell); TableCell paymentTypeCell = new TableCell(); paymentTypeCell.Controls.Add(new Label() { Text = paymentTypeList.ElementAt(i).Type }); newRow.Cells.Add(paymentTypeCell); } }
protected void Btn_Update_Click(object sender, EventArgs e) { String paymentTypeName = PaymentTypeController.getPaymentTypeByID(Convert.ToInt32(Request.QueryString["paymentTypeID"])).Type; int paymentTypeID = Convert.ToInt32(Request.QueryString["paymentTypeID"]); String type = PaymentTypeTxt.Text; if (paymentTypeName != type) { int isValid = PaymentTypeController.PaymentTypeValidation(type); if (isValid == -1) { TypeLabel.Text = "Type must be filled, unique and consist of 3 chars or more"; } else if (isValid == -2) { TypeLabel.Text = "Type must consist of 3 chars or more and unique"; } else if (isValid == -3) { TypeLabel.Text = "Type must be unique"; } else { PaymentTypeController.update(paymentTypeID, type); Response.Redirect("ViewPaymentType.aspx"); } } else { Response.Redirect("ViewPaymentType.aspx"); } }
protected void deleteRedirect_Click(object sender, EventArgs e) { int id = Int32.Parse((sender as LinkButton).CommandArgument); PaymentType pt = PaymentTypeRepository.db.PaymentTypes.Where(payType => payType.PaymentTypesId == id).FirstOrDefault(); HeaderTransaction ht = TransactionRepository.db.HeaderTransactions.Where(headTran => headTran.PaymentTypeId == id).FirstOrDefault(); int idIsUseOnTransaction; try { idIsUseOnTransaction = ht.PaymentTypeId; } catch { idIsUseOnTransaction = 0; } if (idIsUseOnTransaction == pt.PaymentTypesId) { validateDeleteIsReferencesID.Text = "Payment Type cannot be delete because it reference on other table"; } else { PaymentTypeController.deletePaymentType(id); refreshTable(); } }
protected void Load_PaymentType() { int paymentId = Convert.ToInt32(Request.QueryString["ID"]); PaymentType pay = PaymentTypeController.getPaymentTypeById(paymentId); TableRow newRow = new TableRow(); PaymentTypeTable.Controls.Add(newRow); TableCell paymentTypeIDCell = new TableCell(); paymentTypeIDCell.Controls.Add(new Label() { Text = pay.ID.ToString() }); newRow.Cells.Add(paymentTypeIDCell); TableCell paymentTypeCell = new TableCell(); paymentTypeCell.Controls.Add(new Label() { Text = pay.Type }); newRow.Cells.Add(paymentTypeCell); }
public async void BulkInsert_No_Errors() { PaymentTypeControllerMockFacade mock = new PaymentTypeControllerMockFacade(); var mockResponse = new CreateResponse <ApiPaymentTypeResponseModel>(new FluentValidation.Results.ValidationResult()); mockResponse.SetRecord(new ApiPaymentTypeResponseModel()); mock.ServiceMock.Setup(x => x.Create(It.IsAny <ApiPaymentTypeRequestModel>())).Returns(Task.FromResult <CreateResponse <ApiPaymentTypeResponseModel> >(mockResponse)); PaymentTypeController controller = new PaymentTypeController(mock.ApiSettingsMoc.Object, mock.LoggerMock.Object, mock.TransactionCoordinatorMock.Object, mock.ServiceMock.Object, mock.ModelMapperMock.Object); controller.ControllerContext = new ControllerContext(); controller.ControllerContext.HttpContext = new DefaultHttpContext(); var records = new List <ApiPaymentTypeRequestModel>(); records.Add(new ApiPaymentTypeRequestModel()); IActionResult response = await controller.BulkInsert(records); response.Should().BeOfType <OkObjectResult>(); (response as OkObjectResult).StatusCode.Should().Be((int)HttpStatusCode.OK); var result = (response as OkObjectResult).Value as List <ApiPaymentTypeResponseModel>; result.Should().NotBeEmpty(); mock.ServiceMock.Verify(x => x.Create(It.IsAny <ApiPaymentTypeRequestModel>())); }
public async void Patch_No_Errors() { PaymentTypeControllerMockFacade mock = new PaymentTypeControllerMockFacade(); var mockResult = new Mock <UpdateResponse <ApiPaymentTypeResponseModel> >(); mockResult.SetupGet(x => x.Success).Returns(true); mock.ServiceMock.Setup(x => x.Update(It.IsAny <int>(), It.IsAny <ApiPaymentTypeRequestModel>())) .Callback <int, ApiPaymentTypeRequestModel>( (id, model) => model.Name.Should().Be("A") ) .Returns(Task.FromResult <UpdateResponse <ApiPaymentTypeResponseModel> >(mockResult.Object)); mock.ServiceMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <ApiPaymentTypeResponseModel>(new ApiPaymentTypeResponseModel())); PaymentTypeController controller = new PaymentTypeController(mock.ApiSettingsMoc.Object, mock.LoggerMock.Object, mock.TransactionCoordinatorMock.Object, mock.ServiceMock.Object, new ApiPaymentTypeModelMapper()); controller.ControllerContext = new ControllerContext(); controller.ControllerContext.HttpContext = new DefaultHttpContext(); var patch = new JsonPatchDocument <ApiPaymentTypeRequestModel>(); patch.Replace(x => x.Name, "A"); IActionResult response = await controller.Patch(default(int), patch); response.Should().BeOfType <OkObjectResult>(); (response as OkObjectResult).StatusCode.Should().Be((int)HttpStatusCode.OK); mock.ServiceMock.Verify(x => x.Update(It.IsAny <int>(), It.IsAny <ApiPaymentTypeRequestModel>())); }
protected void doInsertPaymentType(object sender, EventArgs e) { String type = paymentTypeNameId.Text; PaymentType pt = PaymentTypeRepository.db.PaymentTypes.Where(payType => payType.Type.Equals(type)).FirstOrDefault(); String paymentTypeIsExist; try { paymentTypeIsExist = pt.Type; } catch { paymentTypeIsExist = ""; } if (type.Length == 0) { errorMsgId.Text = "Please fill the payment type name"; } else if (type.Length < 3) { errorMsgId.Text = "Payment type name must be 3 character or more"; } else if (type.Equals(paymentTypeIsExist)) { errorMsgId.Text = "Payment type name is already exist, please input different type of payment"; } else { PaymentTypeController.insertPaymentType(type); Response.Redirect("ViewPaymentType.aspx"); } }
public frmPayment() { InitializeComponent(); _paymentController = new PaymentController(); _userController = new UserController(); _ptController = new PaymentTypeController(); _prController = new PaymentReasonController(); }
protected string getPaymentType() { string paymentId = HttpContext.Current.Session["user_pay"].ToString(); PaymentType pays = PaymentTypeController.getPaymentTypeById(Convert.ToInt32(paymentId)); return(pays.Type); }
protected void Btn_Delete_Click(object sender, EventArgs e) { Button currentButton = (Button)sender; String id = currentButton.ID.Substring(0, currentButton.ID.IndexOf('d')); int selectedRowID = Int32.Parse(id); PaymentTypeController.delete(selectedRowID); Response.Redirect("ViewPaymentType.aspx"); }
protected void Page_Load(object sender, EventArgs e) { if (Session["user"] == null || !UserController.isAdmin(Int32.Parse(Session["user"].ToString()))) { Response.Redirect("/View/Home.aspx"); return; } PaymentTypeTable.DataSource = PaymentTypeController.getAllPaymentTypes(); PaymentTypeTable.DataBind(); }
protected void linkSelect_Click(object sender, EventArgs e) { int paymentTypeID = Int32.Parse((sender as LinkButton).CommandArgument); currPaymentType = PaymentTypeController.getPaymentTypeByID(paymentTypeID); PaymentTypeNameBox.Text = currPaymentType.PaymentTypeName; UpdatePaymentTypeButton.Enabled = true; DeletePaymentTypeButton.Enabled = true; }
private void attachProperties(int paymentTypeID) { if (!IsPostBack) { currentPaymentType = PaymentTypeController.getPaymentTypeByID(paymentTypeID); if (currentPaymentType == null) { Response.Redirect("ViewPaymentType.aspx"); return; } PaymentTypeNameBox.Text = currentPaymentType.PaymentTypeName; } }
private void deleteButton_Click(object sender, EventArgs e) { Button currButton = (Button)sender; int selectedRowIndex = 0; if (int.TryParse(currButton.ID.Substring(0, currButton.ID.Length - 2), out selectedRowIndex)) { int paymentId = int.Parse(((Label)PaymentTypeTable.Rows[selectedRowIndex].Cells[1].Controls[0]).Text); PaymentTypeController.deletePaymentType(paymentId); Response.Redirect("./ViewPaymentType.aspx"); } }
protected void Button1_Click(object sender, EventArgs e) { Response response = PaymentTypeController.InsertPaymentType(paytypeTxt.Text); if (response.successStatus == true) { Response.Write("<script>alert('PaymentType has been added')</script>"); Response.Redirect(Request.RawUrl); } else { lblError.Text = response.message; } }
protected void Load_PaymentTypes() { List <PaymentType> paymentTypeList = PaymentTypeController.getAllPaymentTypes(); for (int i = 0; i < paymentTypeList.Count; i++) { TableRow newRow = new TableRow(); PaymentTypeTable.Controls.Add(newRow); TableCell paymentTypeIdCell = new TableCell(); paymentTypeIdCell.Controls.Add(new Label() { Text = paymentTypeList.ElementAt(i).ID.ToString() }); newRow.Cells.Add(paymentTypeIdCell); TableCell typeCell = new TableCell(); typeCell.Controls.Add(new Label() { Text = paymentTypeList.ElementAt(i).Type }); newRow.Cells.Add(typeCell); User user = UserController.getUserByID(Convert.ToInt32(Session["auth_user"])); if (user != null) { TableCell ActionCell = new TableCell(); int id = paymentTypeList.ElementAt(i).ID; if (user.RoleID == 3) { Button btnUpdate = new Button { CssClass = "btn-primary", Text = "Update", ID = id.ToString() }; Button btnDelete = new Button { CssClass = "btn-danger", Text = "Delete", ID = id.ToString() + "delete" }; btnUpdate.Click += new EventHandler(Btn_Update_Click); btnDelete.Click += new EventHandler(Btn_Delete_Click); ActionCell.Controls.Add(btnUpdate); ActionCell.Controls.Add(btnDelete); newRow.Cells.Add(ActionCell); } else { Response.Redirect("Home.aspx"); } } } }
protected void InsertPaymentTypeBtn_Click(object sender, EventArgs e) { string paymentTypeName = TxtPaymentType.Text; string errorMessage = ""; PaymentTypeController.createPaymentType(paymentTypeName, out errorMessage); if (errorMessage != "Success") { ErrorLbl.Text = errorMessage; } else { Response.Redirect("./ViewPaymentType.aspx"); } }
protected void insertPaymentType(object sender, EventArgs e) { string paymentTypeName = PaymentTypeNameBox.Text; string error = PaymentTypeController.insertPaymentType(paymentTypeName); if (error == "") { Response.Redirect("ViewPaymentType.aspx"); } else { ErrorMessage.Text = error; } }
public async void Get_Not_Exists() { PaymentTypeControllerMockFacade mock = new PaymentTypeControllerMockFacade(); mock.ServiceMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <ApiPaymentTypeResponseModel>(null)); PaymentTypeController controller = new PaymentTypeController(mock.ApiSettingsMoc.Object, mock.LoggerMock.Object, mock.TransactionCoordinatorMock.Object, mock.ServiceMock.Object, mock.ModelMapperMock.Object); controller.ControllerContext = new ControllerContext(); controller.ControllerContext.HttpContext = new DefaultHttpContext(); IActionResult response = await controller.Get(default(int)); response.Should().BeOfType <StatusCodeResult>(); (response as StatusCodeResult).StatusCode.Should().Be((int)HttpStatusCode.NotFound); mock.ServiceMock.Verify(x => x.Get(It.IsAny <int>())); }
public async Task CreatePaymentType_Returns_CreatedAtRouteResult() { //Arrange _fixture.MockPaymentTypeRepository.Setup(x => x.CreatePaymentTypeAsync(It.IsAny <CreatePaymentTypeDto>())) .ReturnsAsync(_fixture.CreatePaymentTypeDtoResult); var controller = new PaymentTypeController(_fixture.MockPaymentTypeRepository.Object); //Act var result = await controller.CreatePaymentType(_fixture.ValidCreatePaymentTypeDto, _fixture.ApiVersion); //Assert var objectResult = result.Should().BeOfType <CreatedAtRouteResult>().Subject; objectResult.StatusCode.Should().Be(201); objectResult.RouteValues !["id"].Should().Be(3);
protected void Delete_Click(object sender, EventArgs e) { int id = Int32.Parse((sender as LinkButton).CommandArgument); string messageError = PaymentTypeController.delete(id); if (messageError != "") { lblErrorViewPaymentType.Text = messageError; } else { PaymentTypeHandler.remove(id); Load_PaymentType(); Response.Redirect(Constant.Routes.VIEW_PAYMENT_TYPE); lblErrorViewPaymentType.Text = "Payment type has been deleted"; } }
protected void Button1_Click(object sender, EventArgs e) { int payId = Int32.Parse(Request.QueryString["payId"]); Debug.Print(paytypeTxt.Text); Response response = PaymentTypeController.UpdatePaymentType(payId, paytypeTxt.Text); if (response.successStatus == true) { Response.Write("<script>alert('Product updated successfully')</script>"); Response.Redirect(Request.RawUrl); } else { lblError.Text = response.message; } }
protected void Updatebtn_Click(object sender, EventArgs e) { int id = Int32.Parse(Request.QueryString["id"]); string messageError = ""; messageError = PaymentTypeController.update(updateTxt.Text); if (messageError != "") { lblerror.Text = messageError; } else { PaymentTypeHandler.update(id, updateTxt.Text); lblerror.Text = "Update Success"; } }
public async Task GetPaymentTypes_Returns_OkObjectResult() { //Arrange _fixture.MockPaymentTypeRepository.Setup(x => x.GetPaymentTypesAsync()) .ReturnsAsync(_fixture.PaymentTypes); var controller = new PaymentTypeController(_fixture.MockPaymentTypeRepository.Object); //Act var result = await controller.GetPaymentTypes(); //Assert var okResult = result.Should().BeOfType <OkObjectResult>().Subject; var paymentTypes = okResult.Value.Should().BeAssignableTo <IEnumerable <GetPaymentTypeDto> >().Subject; okResult.StatusCode.Should().Be(200); paymentTypes.Should().HaveCount(2); }
public async void Delete_Errors() { PaymentTypeControllerMockFacade mock = new PaymentTypeControllerMockFacade(); var mockResult = new Mock <ActionResponse>(); mockResult.SetupGet(x => x.Success).Returns(false); mock.ServiceMock.Setup(x => x.Delete(It.IsAny <int>())).Returns(Task.FromResult <ActionResponse>(mockResult.Object)); PaymentTypeController controller = new PaymentTypeController(mock.ApiSettingsMoc.Object, mock.LoggerMock.Object, mock.TransactionCoordinatorMock.Object, mock.ServiceMock.Object, mock.ModelMapperMock.Object); controller.ControllerContext = new ControllerContext(); controller.ControllerContext.HttpContext = new DefaultHttpContext(); IActionResult response = await controller.Delete(default(int)); response.Should().BeOfType <ObjectResult>(); (response as ObjectResult).StatusCode.Should().Be((int)HttpStatusCode.UnprocessableEntity); mock.ServiceMock.Verify(x => x.Delete(It.IsAny <int>())); }
protected void Page_Load(object sender, EventArgs e) { if (Session["auth_user"] != null) { if (UserController.getUserByID(Convert.ToInt32(Session["auth_user"])).RoleID != 3) { Response.Redirect("Home.aspx"); } } else { Response.Redirect("Home.aspx"); } if (!IsPostBack) { PaymentTypeTxt.Text = PaymentTypeController.getPaymentTypeByID(Convert.ToInt32(Request.QueryString["paymentTypeID"])).Type; } }
protected void UpdatePaymentTypeBtn_Click(object sender, EventArgs e) { int id = Convert.ToInt32(Request.QueryString["ID"]); String paymentType = TxtPaymentType.Text; string errorMessage = ""; PaymentTypeController.updatePaymentType(id, paymentType, out errorMessage); if (errorMessage != "Success") { ErrorLbl.Text = errorMessage; ErrorLbl.Visible = true; } else { ErrorLbl.Visible = false; Response.Redirect("./ViewPaymentType.aspx"); } }
protected void NewPaymentbtn_Click(object sender, EventArgs e) { String type = Typetxt.Text; String messageError = ""; messageError = PaymentTypeController.insert(type); if (messageError != "") { insLabelError.Text = messageError; } else { PaymentTypeHandler.add(type); insLabelError.Text = "Payment type has been registered"; } }
public async void All_Not_Exists() { PaymentTypeControllerMockFacade mock = new PaymentTypeControllerMockFacade(); mock.ServiceMock.Setup(x => x.All(It.IsAny <int>(), It.IsAny <int>())).Returns(Task.FromResult <List <ApiPaymentTypeResponseModel> >(new List <ApiPaymentTypeResponseModel>())); PaymentTypeController controller = new PaymentTypeController(mock.ApiSettingsMoc.Object, mock.LoggerMock.Object, mock.TransactionCoordinatorMock.Object, mock.ServiceMock.Object, mock.ModelMapperMock.Object); controller.ControllerContext = new ControllerContext(); controller.ControllerContext.HttpContext = new DefaultHttpContext(); IActionResult response = await controller.All(1000, 0); response.Should().BeOfType <OkObjectResult>(); (response as OkObjectResult).StatusCode.Should().Be((int)HttpStatusCode.OK); var items = (response as OkObjectResult).Value as List <ApiPaymentTypeResponseModel>; items.Should().BeEmpty(); mock.ServiceMock.Verify(x => x.All(It.IsAny <int>(), It.IsAny <int>())); }
public async void Update_NotFound() { PaymentTypeControllerMockFacade mock = new PaymentTypeControllerMockFacade(); var mockResult = new Mock <UpdateResponse <ApiPaymentTypeResponseModel> >(); mockResult.SetupGet(x => x.Success).Returns(false); mock.ServiceMock.Setup(x => x.Update(It.IsAny <int>(), It.IsAny <ApiPaymentTypeRequestModel>())).Returns(Task.FromResult <UpdateResponse <ApiPaymentTypeResponseModel> >(mockResult.Object)); mock.ServiceMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <ApiPaymentTypeResponseModel>(null)); PaymentTypeController controller = new PaymentTypeController(mock.ApiSettingsMoc.Object, mock.LoggerMock.Object, mock.TransactionCoordinatorMock.Object, mock.ServiceMock.Object, new ApiPaymentTypeModelMapper()); controller.ControllerContext = new ControllerContext(); controller.ControllerContext.HttpContext = new DefaultHttpContext(); IActionResult response = await controller.Update(default(int), new ApiPaymentTypeRequestModel()); response.Should().BeOfType <StatusCodeResult>(); (response as StatusCodeResult).StatusCode.Should().Be((int)HttpStatusCode.NotFound); mock.ServiceMock.Verify(x => x.Get(It.IsAny <int>())); }