public WhenAnEmployeeDeleteIsRequested() { Id = Guid.NewGuid(); EmployeeApi .Setup(e => e.DeleteEmployee(It.Is <Guid>(i => i == Id))); }
public WhenTheEmployeeListIsRequested() { EmployeeList = new EmployeeSeed().GetDetailedEmployeeList(10); EmployeeApi .Setup(e => e.GetAllEmployees()) .ReturnsAsync(EmployeeList); }
public ActionResult Employee([FromBody] EmployeeApi employeeApi) { if (employeeApi == null) { return(Json(new ResultsJson(new Message(CodeMessage.PostNull, "PostNull"), null))); } return(Json(Global.BUSS.BussResults(this, employeeApi, _accessor))); }
public WhenAnEmployeeCreationIsRequested() { Employee = new EmployeeSeed().GetSingleEmployee(); EmployeeApi .Setup(e => e.CreateEmployee(It.Is <Employee>(i => i == Employee))) .Callback((Employee e) => ProcessedEmployee = e) ; }
public WhenASingleEmployeeIsRequested() { Id = Guid.NewGuid(); Employee = new EmployeeSeed().GetDetailedEmployeeWithId(Id); EmployeeApi .Setup(e => e.GetEmployee(It.Is <Guid>(i => i == Id))) .ReturnsAsync(Employee); }
public XucEmployeeInfo(bool addOrUpdate) { InitializeComponent(); _addOrUpdate = addOrUpdate; _api = new EmployeeApi(); _propertiesApi = new SystemSettingApi(); }
static async Task Main() { var ui = new UiHelper(); var employeeApi = new EmployeeApi("http://51.148.170.137:9111/"); var processor = new CommandProcessor(employeeApi); while (true) { var commandInt = ui.ShowMenu(); switch (commandInt) { case 6: return; case 1: Console.WriteLine(await processor.DisplayEmployeeList()); break; case 2: var getId = ui.GetGuidId(); if (getId != Guid.Empty) { Console.WriteLine(await processor.DisplaySingleEmployee(getId)); } break; case 3: var createEmployee = ui.GetCreateEmployee(); if (createEmployee != null) { Console.WriteLine(await processor.CreateNewEmployee(createEmployee)); } break; case 4: var updateEmployee = ui.GetUpdateEmployee(); if (updateEmployee != null) { Console.WriteLine(await processor.UpdateEmployee(updateEmployee)); } break; case 5: var deleteId = ui.GetGuidId(); if (deleteId != Guid.Empty) { Console.WriteLine(await processor.DeleteEmployee(deleteId)); } break; } Console.WriteLine("Press enter to continue"); Console.ReadKey(); } }
public FrmEmployees() { InitializeComponent(); _api = new EmployeeApi(); }
public void EmployeeApiIsCalled() => EmployeeApi.Verify(e => e.GetEmployee(It.Is <Guid>(i => i == Id)), Times.Once);
public void EmployeeApiIsCalled() => EmployeeApi.Verify(e => e.GetAllEmployees(), Times.Once);
public void EmployeeApiIsCalled() => EmployeeApi.Verify(e => e.UpdateEmployee(It.Is <Employee>(i => i == Employee)), Times.Once);
public EmployeeApiTests() { instance = new EmployeeApi(); }
public JsonResult setOrder([FromBody] OrderViewModel order, string accessToken) { var orderApi = new OrderApi(); var customerApi = new CustomerApi(); var employeeApi = new EmployeeApi(); var productApi = new ProductApi(); //Get CustomerId from token int number; order.CustomerID = 0; if (Int32.TryParse(getCustomerIdFromToken(accessToken), out number)) { order.CustomerID = number; } //Check customer exist if customerId != 0 (customerId default is 0) if (order.CustomerID != 0 && (order.CustomerID == null || customerApi.GetActive().Where(q => q.ID == order.CustomerID) == null)) { return(Json(new { status = new { success = false, status = ConstantManager.STATUS_SUCCESS, message = ConstantManager.MES_CHECK_CUSTOMER_FAIL }, data = new { } })); } //Check employee exist if employeeId != 0 (employeeId is 0 for online Order) order.EmployeeID = null; //Check order details if (order.OrderDetails == null || order.OrderDetails.Count() == 0) { return(Json(new { status = new { success = false, status = ConstantManager.STATUS_SUCCESS, message = ConstantManager.MES_CHECK_ORDER_DETAIL_FAIL }, data = new { } })); } //Calculate order decimal totalAmount = 0; foreach (var orderdetail in order.OrderDetails) { //Check Order detail ProductId not null and product exist if (orderdetail.ProductID == null) { return(Json(new { status = new { success = false, status = ConstantManager.STATUS_SUCCESS, message = ConstantManager.MES_CHECK_PRODUCT_FAIL }, data = new { } })); } //Check product exist var product = productApi.GetActive().Where(q => q.ID == orderdetail.ProductID).FirstOrDefault(); if (product == null) { return(Json(new { status = new { success = false, status = ConstantManager.STATUS_SUCCESS, message = ConstantManager.MES_CHECK_PRODUCT_FAIL }, data = new { } })); } //Check Order detail Quantity if (orderdetail.Quantity == null || orderdetail.Quantity < 1) { return(Json(new { status = new { success = false, status = ConstantManager.STATUS_SUCCESS, message = ConstantManager.MES_CHECK_QUANTITY_FAIL }, data = new { } })); } //Set OrderDetail orderdetail.Price = product.Price; orderdetail.Amount = product.Price * orderdetail.Quantity; //Calculate total amount totalAmount += orderdetail.Amount; } //Create payment List <PaymentViewModel> listPayment = new List <PaymentViewModel>(); PaymentViewModel payment = new PaymentViewModel(); payment.Amount = totalAmount; payment.Type = (int)PaymentTypeEnum.Cash; listPayment.Add(payment); //Create Order order.CheckInDate = DateTime.Now; order.TotalAmount = totalAmount; order.Payments = listPayment; order.InvoiceID = generateInvoiceID(); order.Status = (int)OrderStatusEnum.Finish; var rs = orderApi.CreateOrder(order); if (rs == false) { return(Json(new { status = new { success = false, status = ConstantManager.STATUS_SUCCESS, message = ConstantManager.MES_CREATE_ORDER_FAIL }, data = new { } })); } return(Json(new { status = new { success = true, status = ConstantManager.STATUS_SUCCESS, message = ConstantManager.MES_CREATE_ORDER_SUCCESS }, data = new { data = new { InvoiceID = order.InvoiceID, Status = order.Status } } })); }