public async Task <LocationUpdateResponse> ProvinceUpdate(LocationUpdateRequest request) { LocationUpdateResponse response = new LocationUpdateResponse(); try { var user = await _context.GetCurrentCustomer(); var command = request.ToUpdateCommand(user.Id); var result = await _locationService.SendCommand(command); if (result.IsSucess) { response.SetSucess(); } else { response.SetFail(result.Message); } } catch (Exception e) { response.SetFail(e); _logger.LogError(e, e.Message, request); } return(response); }
public async Task <BaseResponse> GiftCodeCampaignAddOrChange(GiftCodeCampaignAddOrChangeRequest request) { BaseResponse response = new BaseResponse(); try { CommandResult result; var currentUser = await _currentContext.GetCurrentCustomer(); if (string.IsNullOrEmpty(request.Id)) { var command = request.ToCommand(currentUser.Id); result = await _giftcodeService.SendCommand(command); } else { var command = request.ToCommand(currentUser.Id, request.Version, request.ShardId); result = await _giftcodeService.SendCommand(command); } if (result.IsSucess) { response.SetSucess(); } else { response.SetFail(result.Message); } } catch (Exception e) { response.SetFail(e); _logger.LogError(e, e.Message, request); } return(response); }
public async Task <BaseResponse> Add(MeasureUnitAddRequest request) { BaseResponse response = new BaseResponse(); try { var userLogin = await _context.GetCurrentCustomer(); var command = request.ToCommand(userLogin.Id); CommandResult result = await _measureUnitService.SendCommand(command); if (result.IsSucess) { response.SetSucess(); } else { response.SetFail(result.Message); } } catch (Exception e) { response.SetFail(e); _logger.LogError(e, e.Message, request); } return(response); }
public async Task <BannerAddOrChangeResponse> BannerAddOrChange(BannerAddOrChangeRequest request) { var response = new BannerAddOrChangeResponse(); try { var userLogin = await _context.GetCurrentCustomer(); if (string.IsNullOrEmpty(request.Id)) { //add request.Status = EnumDefine.CommonStatusEnum.New; var command = request.ToCommandAdd(userLogin.Id); var result = await _bannerService.SendCommand(command); if (result.IsSucess) { response.SetSucess(); } else { response.SetFail(result.Message); } } else { var data = await _bannerService.GetBannerById(request.Id); if (data == null || string.IsNullOrEmpty(data.Id)) { response.SetFail("Banner not found!"); return(response); } //update var command = request.ToCommandChange(userLogin.Id); var result = await _bannerService.SendCommand(command); if (result.IsSucess) { response.SetSucess(); } else { response.SetFail(result.Message); } } } catch (Exception e) { response.SetFail(e); _logger.LogError(e, e.Message, request); } return(response); }
public async Task <TemplateConfigAddOrChangeResponse> TemplateConfigAddOrChange(TemplateConfigAddOrChangeRequest request) { var response = new TemplateConfigAddOrChangeResponse(); try { var userLogin = await _context.GetCurrentCustomer(); if (string.IsNullOrEmpty(request.Id)) { //add var command = request.ToCommandAdd(userLogin.Id); var result = await _templateService.SendCommand(command); if (result.IsSucess) { response.SetSucess(); } else { response.SetFail(result.Message); } } else { var data = await _templateService.GetTemplateConfigById(request.Id); if (data == null || string.IsNullOrEmpty(data.Id)) { response.SetFail("Template config not found!"); return(response); } //update var command = request.ToCommandChange(userLogin.Id); var result = await _templateService.SendCommand(command); if (result.IsSucess) { response.SetSucess(); } else { response.SetFail(result.Message); } } } catch (Exception e) { response.SetFail(e); _logger.LogError(e, e.Message, request); } return(response); }
public async Task <ProductAttributeCrudResponse> AddOrUpdate(ProductAttributeCrudRequest request) { var response = new ProductAttributeCrudResponse(); try { var user = await _context.GetCurrentCustomer(); var command = request.ToCommand(user.Id); var result = await _productAttributeService.SendCommand(command); if (result.IsSucess) { response.SetSucess(); } else { response.SetFail(result.Message); } } catch (Exception e) { response.SetFail(e); _logger.LogError(e, e.Message, request); } return(response); }
public async Task <string> Upload(string fileName, byte[] bytes) { var user = await _currentContext.GetCurrentCustomer(); string createdUid = user.Id; return(await _fileService.Upload(createdUid, fileName, bytes)); }
public async Task <CustomerAddOrChangeResponse> AddOrChange(CustomerAddOrChangeRequest request) { CustomerAddOrChangeResponse response = new CustomerAddOrChangeResponse(); try { var userLogin = await _context.GetCurrentCustomer(); CommandResult result; if (string.IsNullOrEmpty(request.Id)) { long systemIdentity = await _commonService.GetNextId(typeof(Customer)); string code = Common.Common.GenerateCodeFromId(systemIdentity, 3); var command = request.ToCommand(_context.Ip, userLogin.Id, code); result = await _customerService.SendCommand(command); } else { var command = request.ToCommand(_context.Ip, userLogin.Id, request.Version); result = await _customerService.SendCommand(command); } if (result.IsSucess) { response.SetSucess(); } else { response.SetFail(result.Message); } } catch (Exception e) { response.SetFail(e); _logger.LogError(e, e.Message, request); } return(response); }
public async Task <RoleActionMappingsResponse> PermissionGetAll() { RoleActionMappingsResponse response = new RoleActionMappingsResponse(); try { var user = await _context.GetCurrentCustomer(); RRoleActionMapping[] roleActionMappings = await _roleService.RoleActionMappingGetByCustomerIdFromDb(user.Id); response.ActionIds = roleActionMappings.Select(p => p.ActionId).ToArray(); } catch (Exception e) { response.SetFail(e); _logger.LogError(e, e.Message); } return(response); }