public async Task <IActionResult> Delete(int id) { await Task.Delay(3000); //await unitOfWork.Products.DeleteByIdAsync(id); return(AppResponse.Success()); }
public async Task <ActionResult <PaymentDetails> > GetPayment(string payID) { int merchantID = Authenticate(); if (merchantID == -3) { return(new ObjectResult(HttpStatusCode.ExpectationFailed)); } if (merchantID < 0) { return(new ObjectResult(HttpStatusCode.Unauthorized)); } PaymentDetails paymentDetails; try { paymentDetails = unitOfWork.Payment.getPaymentDetails(merchantID, payID); return(AppResponse.Success(paymentDetails)); // paymentDetails = await _paymentService.getPaymentDetails(merchantID, payID); // return Ok(paymentDetails); } catch (Exception ex) { return(Unauthorized(ex.Message)); } }
public async Task <IActionResult> Delete(string rec_id) { var user = await unitOfWork.Users.DeleteByIdAsync(rec_id); return(AppResponse.Success()); }
public async Task <IActionResult> GetAll() { logger.LogInformation("called ProductController"); var data = await unitOfWork.Products.GetAllAsync(); return(AppResponse.Success(data)); }
public async Task <IActionResult> Authenticate([FromBody] LoginDto model) { if (string.IsNullOrEmpty(model.username) || string.IsNullOrEmpty(model.password)) { return(AppResponse.BadRequest("All fields are required")); } ModelValidator.Validate(model); string ipaddress = Helper.getIPAddress(this.Request); var authResponse = await authService.Authenticate(model, ipaddress); if (authResponse == null || authResponse.Token == null) { return(AppResponse.Unauthorized("Invalid Token")); } if (string.IsNullOrEmpty(authResponse.Token.AccessToken) || string.IsNullOrEmpty(authResponse.Token.RefreshToken)) { return(AppResponse.Unauthorized("Invalid Token")); } setTokenCookie(authResponse.Token.RefreshToken); return(AppResponse.Success(authResponse)); }
public async Task <IActionResult> deleteProfileId(int?id) { if (id.HasValue) { var user = await unitOfWork.Users.DeleteByIdAsync(id.Value); } return(AppResponse.Success()); }
public async Task <ActionResult <UserProfile> > GetUserEmailAsync(string email) { var data = await unitOfWork.Users.GetUserByEmailAsync(email); if (data == null) { return(AppResponse.NotFound("User Not Found")); } return(AppResponse.Success(data)); }
public async Task <ActionResult <UserProfile> > GetById(int id) { var data = await unitOfWork.Users.GetByIdAsync(id); if (data == null) { return(AppResponse.NotFound("User Not Found")); } return(AppResponse.Success(data)); }
public async Task <IActionResult> GetById(string id) { var data = await unitOfWork.Products.GetByIdAsync(id); if (data == null) { return(NotFound("Product Not Found")); } return(AppResponse.Success(data)); }
public async Task <AppResponse> Handle(TCommand request, CancellationToken cancellationToken) { return(await Task.Factory.StartNew(() => { Exception = new TransactionFailedException(); var fromErrorCode = From.DecreaseBalance(request.Amount, request.TransactionId); CheckDecreaseBalanceResult(fromErrorCode, request); var toErrorCode = To.IncreaseBalance(request.Amount, request.TransactionId); CheckIncreaseBalanceResult(toErrorCode, request); return AppResponse.Success(null); })); }
public async Task <ActionResult <CustomerCart> > CreateOrUpdatePaymentIntent(string cartId) { var basket = await paymentService.CreateOrUpdatePaymentIntent(cartId); if (basket == null) { return(BadRequest(new { code = 400, message = "Problem with your basket" })); } return(AppResponse.Success(basket)); }
public async Task <IActionResult> Add([FromBody] RegisterDto model) { #if (DEBUG) if (model.Password != model.ConfirmPassword) { model.ConfirmPassword = model.Password; } #endif var existingUser = await unitOfWork.Users.GetUserByEmailAsync(model.Email); if (existingUser != null) { throw new AppException("An account with the same username already exists"); } var salt = Helper.GenerateSalt(); var _user = new UserProfile() { email = model.Email, username = Guid.NewGuid().ToString().Replace("-", "") }; (_user.password_hash, _user.password_salt) = Helper.GetPasswordHash(model.Password); var encPassword = Helper.Encrypt(model.Password); _user.last_modified = DateTime.UtcNow; _user.created_on = DateTime.UtcNow; _user.password = encPassword; if (model.Email.ToLower().IndexOf("admin") > -1) { _user.role = Role.Admin; } else if (model.Email.ToLower().IndexOf("user") > -1) { _user.role = Role.User; } else { _user.role = Role.Client; } _user.language = Langauge.English; _user.last_modified = DateTime.UtcNow; _user.created_on = DateTime.UtcNow; var result = await unitOfWork.Users.AddUserAsync(_user); _user.user_id = result; return(AppResponse.Success(_user));; }
public async Task <IActionResult> Register(string Name, string Email, string Password, string ConfirmPassword) { //if (!ModelState.IsValid) //{ // var response = new // { // Status = 403, // Message = "ERROR", // Errors = CustomValidator.GetErrorsByModel(ModelState) // }; //} if (string.IsNullOrEmpty(Name) || string.IsNullOrEmpty(Email) || string.IsNullOrEmpty(Password) || string.IsNullOrEmpty(ConfirmPassword)) { return(BadRequest(AppResponse.BadRequest("All fields are required"))); } var model = new RegisterDto() { Name = Name, Email = Email, Password = Password, ConfirmPassword = ConfirmPassword, }; var result = await authService.SignUp(model, Request.Headers["origin"]); // if (result != 1) // { // var response = new // { // Message = "ERROR", // Status = 500, // Errors = CustomValidator.GetErrorsByIdentotyResult(result) // }; // } var response = new { Status = 200, Message = "OK" }; return(AppResponse.Success(response)); }
public async Task <IActionResult> RenewAccessToken([FromBody] RequestAuthDto request) { ModelValidator.Validate(request); var refreshToken = Request.Cookies["refreshToken"]; string ipaddress = Helper.getIPAddress(this.Request); var authResponse = await authService.RenewAccessToken(request, ipaddress); if (authResponse == null) { return(AppResponse.Unauthorized("Invalid Token")); } if (string.IsNullOrEmpty(authResponse.Token.AccessToken) || string.IsNullOrEmpty(authResponse.Token.RefreshToken)) { return(AppResponse.Unauthorized("Invalid Token")); } setTokenCookie(authResponse.Token.RefreshToken); return(AppResponse.Success(authResponse)); }
public async Task <IActionResult> Register(string Name, string Email, string Password, string ConfirmPassword) { if (string.IsNullOrEmpty(Name) || string.IsNullOrEmpty(Email) || string.IsNullOrEmpty(Password) || string.IsNullOrEmpty(ConfirmPassword)) { return(BadRequest(AppResponse.BadRequest("All fields are required"))); } var model = new RegisterDto() { Name = Name, Email = Email, Password = Password, ConfirmPassword = ConfirmPassword, }; await authService.SignUp(model, Request.Headers["origin"]); return(AppResponse.Success("Registration successful, please check your email for verification instructions")); }
public async Task <IActionResult> GetLanguages() { var data = await unitOfWork.Lookups.GetLanguages(); return(AppResponse.Success(data)); }
public async Task <IActionResult> GetCustomerPayments([FromQuery] long customer_id) { var data = await unitOfWork.Payments.GetCustomerPayments(customer_id); return(AppResponse.Success(data)); }
public async Task <IActionResult> GetOrderDetails(string order_id) { var data = await customerService.GetOrderDetails(order_id); return(AppResponse.Success(data)); }
public async Task <IActionResult> GetCartDetails(string customer_id = "1") { var data = await customerService.GetCartForCustomer(customer_id); return(AppResponse.Success(data)); }
public async Task <IActionResult> ProcessPayment([FromBody] long customer_id, string payment_id) { var data = await unitOfWork.Payments.GetCustomerPayment(customer_id, payment_id); return(AppResponse.Success(data)); }
public async Task <IActionResult> Update(Product product) { var data = await unitOfWork.Products.UpdateAsync(product); return(AppResponse.Success(data)); }