public ResponseDto<TestObjectDto> GetTestMessageById(long messageId) { var testMessage = TestRepository.GetTestMessageById(messageId); if (testMessage != null) { return new ResponseDto<TestObjectDto> { IsSuccessful = true, Payload = new TestObjectDto { Id = testMessage.Id, Message = testMessage.Description, } }; } var failedResponse = new ResponseDto<TestObjectDto> { IsSuccessful = false, }; failedResponse.Messages.Add(new MessageDto { Code = "Data not find", Message = string.Format("Cannot find Messge from DB by ID : {0}", messageId), }); return failedResponse; }
public ResponseDto<List<RolDto>> GetRol() { var response = new ResponseDto<List<RolDto>>(); try { response.Data = RolModel.GetRoles(); if (response.Data.Count > 0) { response.header.Message = ResponseMessages.SuccessMessage.Message; response.header.Code = ResponseMessages.SuccessMessage.Code; } else { response.header.Message = ResponseMessages.NotFoundRegister.Message; response.header.Code = ResponseMessages.NotFoundRegister.Code; } } catch { response.header.Message = ResponseMessages.ServerError.Message; response.header.Code = ResponseMessages.ServerError.Code; } return response; }
public ResponseDto<UserDTO> CreateUser(UserDTO newUser) { var response = new ResponseDto<UserDTO>(); try { if (!UserModel.ExistUser(newUser.Email)) { response.Data = UserModel.CreateUser(newUser); response.header.Message = ResponseMessages.SuccessMessage.Message; response.header.Code = ResponseMessages.SuccessMessage.Code; } else { response.header.Message = ResponseMessages.RepeatedRegister.Message; response.header.Code = ResponseMessages.RepeatedRegister.Code; } } catch { response.header.Message = ResponseMessages.ServerError.Message; response.header.Code = ResponseMessages.ServerError.Code; } return response; }
public ResponseDto<FamilyDto> Login(FamilyDto family) { ResponseDto<FamilyDto> response = new ResponseDto<FamilyDto>(); FamilyModel familyModel = new FamilyModel(); if(familyModel.ExistFamily(family.FamilyName)!=null) { if (familyModel.ValidateFamily(family.FamilyName, family.Password) != null) { response.header.Message = ResponseMessages.SuccessMessage.Message; response.header.Code = ResponseMessages.SuccessMessage.Code; response.Data = familyModel.ValidateFamily(family.FamilyName, family.Password); } else { response.header.Message = ResponseMessages.InvalidUser.Message; response.header.Code = ResponseMessages.InvalidUser.Code; } } else { response.header.Message = ResponseMessages.NotFoundRegister.Message; response.header.Code = ResponseMessages.NotFoundRegister.Code; } return response; }
public ResponseDto <MatchDto> GetMatch(int matchId) { var response = new ResponseDto <MatchDto>() { Object = new MatchDto() }; var match = _matchRepository.GetById(matchId); if (match == null) { response.Errors.Add(ServiceErrors.MATCH_DOES_NOT_EXIST); return(response); } response.Object = _mapper.Map <MatchDto>(match); return(response); }
public ActionResult <ImportingOrderDto> GetAnOrder(int id) { var order = _orderService.GetImportingOrder(id); if (order == null) { List <string> errorMessage = new List <string>(); errorMessage.Add("Đã phát sinh lỗi, vui lòng thử lại"); return(BadRequest(new ResponseDto(errorMessage, 500, order))); } List <string> successMessage = new List <string>(); successMessage.Add("Lấy thông tin thành công"); var responseDto = new ResponseDto(successMessage, 200, order); return(Ok(responseDto)); }
public ActionResult <BaseSearchDto <ImportingOrderDto> > GetAll([FromBody] BaseSearchDto <ImportingOrderDto> searchDto) { var search = _orderService.GetAll(searchDto); if (search == null) { List <string> errorMessage = new List <string>(); errorMessage.Add("Đã phát sinh lỗi, vui lòng thử lại"); return(BadRequest(new ResponseDto(errorMessage, 500, search))); } List <string> successMessage = new List <string>(); successMessage.Add("Lấy danh mục con hàng hoá thành công"); var responseDto = new ResponseDto(successMessage, 200, search); return(Ok(responseDto)); }
public ActionResult <ImportingOrderDto> UpdateImportingOrder([FromBody] ImportingOrderDto order) { var orderDto = _orderService.UpdateImportingOrder(order); if (orderDto == null) { List <string> errorMessage = new List <string>(); errorMessage.Add("Đã phát sinh lỗi, vui lòng thử lại"); return(BadRequest(new ResponseDto(errorMessage, 500, orderDto))); } List <string> successMessage = new List <string>(); successMessage.Add("Sửa thông tin thành công"); var responseDto = new ResponseDto(successMessage, 200, orderDto); return(Ok(responseDto)); }
public ResponseDto<FamilyDto> RegisterFamily(FamilyDto family) { ResponseDto<FamilyDto> response = new ResponseDto<FamilyDto>(); FamilyModel familyModel = new FamilyModel(); if(familyModel.ExistFamily(family.FamilyName)==null) { response.Data = familyModel.RegisterFamily(family); response.header.Message = ResponseMessages.SuccessMessage.Message; response.header.Code = ResponseMessages.SuccessMessage.Code; } else { response.header.Message = ResponseMessages.RepeatedRegister.Message; response.header.Code = ResponseMessages.RepeatedRegister.Code; } return response; }
public IHttpActionResult GetCounters(string path = null) { DirectoryInfo di; if (path != null) di = new DirectoryInfo(path); else { return Ok(ResponseDto<FileDto>.CreateMessage(MessageEnum.Path, false)); } if (!di.Exists) { return Ok(ResponseDto<FileDto>.CreateMessage(MessageEnum.File, false)); } var response = new ResponseDto<FileSizeDto>() { Success = true, Result = FileSizeDto.CreateFromArray(SizeCounter.GetFileSizeCounter(di)) }; return Ok(response); }
public ActionResult <IEnumerable <ImportingOrderDto> > GetAll() { var orders = _orderService.GetAll(); if (orders == null) { List <string> errorMessage = new List <string>(); errorMessage.Add("Đã phát sinh lỗi, vui lòng thử lại"); return(BadRequest(new ResponseDto(errorMessage, 500, orders))); } List <string> successMessage = new List <string>(); successMessage.Add("Lấy danh mục con hàng hoá thành công"); var responseDto = new ResponseDto(successMessage, 200, orders); return(Ok(responseDto)); }
public ResponseDto <List <FicheProductListDto> > GetList(FicheProductGetListCriteriaDto criteriaDto) { FicheProductGetListCriteriaBo criteriaBo = new FicheProductGetListCriteriaBo() { FicheId = criteriaDto.FicheId, Session = Session }; ResponseBo <List <FicheProductListBo> > responseBo = ficheProductBusiness.GetList(criteriaBo); ResponseDto <List <FicheProductListDto> > responseDto = responseBo.ToResponseDto <List <FicheProductListDto>, List <FicheProductListBo> >(); if (responseBo.IsSuccess && responseBo.Bo != null) { responseDto.Dto = new List <FicheProductListDto>(); foreach (FicheProductListBo itemBo in responseBo.Bo) { responseDto.Dto.Add(new FicheProductListDto() { Id = itemBo.Id, ProductId = itemBo.ProductId, ProductName = itemBo.ProductName, ProductTypeId = itemBo.ProductTypeId, Quantity = itemBo.Quantity, UnitPrice = itemBo.UnitPrice, Total = itemBo.Total, DiscountRate = itemBo.DiscountRate, DiscountTotal = itemBo.DiscountTotal, VatRate = itemBo.VatRate, VatTotal = itemBo.VatTotal, GrandTotal = itemBo.GrandTotal, Notes = itemBo.Notes, IsDeleted = itemBo.IsDeleted }); } } return(responseDto); }
public async Task <ResponseDto> GetResponseAsync(RequestDto requestDto) { if (requestDto is null) { _logger.LogError("RequestDto cannot be null"); throw new ArgumentNullException(nameof(requestDto)); } var uri = new UriBuilder(requestDto.ProtocolType.ToString(), requestDto.Host, requestDto.Port); var request = WebRequest.CreateHttp(uri.Uri); var result = new ResponseDto() { Host = requestDto.Host }; try { var response = await request.GetResponseAsync(); var responseResult = (HttpWebResponse)response; result.Date = DateTime.Now; if (responseResult.StatusCode == requestDto.ValidStatusCode) { result.Status = ResponseStatus.Ok; } else { result.Status = ResponseStatus.InvalidResponse; } response.Close(); } catch (Exception) { result.Status = ResponseStatus.Fail; result.Date = DateTime.Now; } return(result); }
public ResponseDto Save(ProductCategoryRawListDto saveDto) { ResponseDto responseDto = new ResponseDto(); ProductCategoryListBo saveBo = new ProductCategoryListBo() { Id = saveDto.Id, Name = saveDto.Name, ParentId = saveDto.ParentId, Session = Session }; ResponseBo responseBo = productCategoryBusiness.Save(saveBo); responseDto = responseBo.ToResponseDto(); return(responseDto); }
private bool TryGetResponseStatusFromResponseDto(out string responseStatus) { responseStatus = string.Empty; try { if (ResponseDto == null) { return(false); } var jsv = ResponseDto.ToJson(); var map = jsv.FromJson <Dictionary <string, string> >(); return(map.TryGetValue("ResponseStatus", out responseStatus)); } catch { return(false); } }
public ResponseDto <Menus> Save([FromBody] Menus request) { ResponseDto <Menus> response = new ResponseDto <Menus>(); var _entity = _appSystemServices.GetEntitys <Menus>(); if (string.IsNullOrEmpty(request.Id.ToStringExtension()) || request.Id.ToInt32() == 0) { request.SetCreateDefault(this.CurrentUser); _appSystemServices.Create <Menus>(request); } else { request.SetModifyDefault(this.CurrentUser); _appSystemServices.Modify <Menus>(request); } return(response); }
public async Task <ResponseDto <BaseModelDto> > Register(RegisterBindingModel model) { var response = new ResponseDto <BaseModelDto>(); var userFindByName = await _userManager.FindByNameAsync(model.UserName); if (userFindByName != null) { response.AddError(Model.Account, Error.account_UserExists); } var userFingByEmail = await _userManager.FindByEmailAsync(model.Email); if (userFingByEmail != null) { response.AddError(Model.Account, Error.account_EmailExists); } if (userFindByName == null && userFingByEmail == null) { var user = new User() { Id = model.UserName, Email = model.Email, PasswordHash = model.Password, FirstName = model.FirstName, LastName = model.LastName, UserName = model.UserName, Avatar = "" }; var result = await _userManager.CreateAsync(user, model.Password); if (result.Errors.Any()) { foreach (var error in result.Errors) { response.AddError(Model.Account, error.Description); } return(response); } } return(response); }
static void GetAllPayments() { ResponseDto responseDto = apiService.GetPaymentAsync().Result; if (responseDto.ResultCode == 1) { if (responseDto.PaymentDetails?.Count > 0) { foreach (IPayment payment in responseDto.PaymentDetails) { payment.Print(); } } else { Console.WriteLine("No payments retrieved"); } } }
public static ResponseDto CheckOTP(CheckOtpRequest request) { request.mobile_number = Common.GetStandardMobileNumber(request.mobile_number); ResponseDto response = new ResponseDto(); AgentBoss agentBoss = null; response.has_resource = 0; try { using (AgentBossDao dao = new AgentBossDao()) { agentBoss = dao.FindByMobileNumber(request.mobile_number); //agentBoss = GetAuthAgentBoss(request.user_id, request.auth_token, response); //agentBoss = GetAuthAgentBossNotAuthToken(request.user_id, response); if (agentBoss == null) { MakeNouserResponse(response); return(response); } bool otpValid = OTPServices.ValidateOTP(agentBoss.AbosID, request.otp_code); OTPServices.RemoveOTP(agentBoss.AbosID, request.otp_code);// Either way remove this otp if it exists. if (otpValid) { agentBoss.StatusId = true; dao.Update(agentBoss); response.code = 0; response.message = MessagesSource.GetMessage("otp.valid"); response.has_resource = 1; return(response); } response.code = 1; response.message = MessagesSource.GetMessage("otp.not.valid"); return(response); } } catch (Exception ex) { response.MakeExceptionResponse(ex); } return(response); }
public ResponseDto UpdateOrderGeneral(ShopOrderGeneralDto updateDto) { ResponseDto responseDto = new ResponseDto(); ShopOrderGeneralBo updateBo = new ShopOrderGeneralBo() { PersonId = updateDto.PersonId, TakesOrder = updateDto.TakesOrder, OrderAccountList = updateDto.OrderAccountList, OrderCurrencyList = updateDto.OrderCurrencyList, Session = Session }; responseDto = shopPersonBusiness.UpdateOrderGeneral(updateBo).ToResponseDto(); return(responseDto); }
public ActionResult <IEnumerable <ProductDetailDto> > GetAll() { var productdetails = _productdetailService.GetAll(); if (productdetails == null) { List <string> errorMessage = new List <string>(); errorMessage.Add("Đã phát sinh lỗi, vui lòng thử lại"); return(BadRequest(new ResponseDto(errorMessage, 500, productdetails))); } List <string> successMessage = new List <string>(); successMessage.Add("Lấy danh mục con hàng hoá thành công"); var responseDto = new ResponseDto(successMessage, 200, productdetails); return(Ok(responseDto)); }
public static ResponseDto <bool> ValidateDeleteCase(Case caseFromDb, User userFromDb) { var response = new ResponseDto <bool>(); if (caseFromDb == null) { response.AddError(CaseErrors.NotFoundById); } if (userFromDb == null) { response.AddError(UserErrors.NotFoundByLogin); } else if (userFromDb.Role == Role.Admin && caseFromDb.Department.Manager != userFromDb) { response.AddError(CaseErrors.NotAllowed); } return(response); }
public ResponseDto <PlayersDto> GetAllPlayers() { var response = new ResponseDto <PlayersDto> { Object = new PlayersDto() }; var players = _playerRepository.GetAll(); if (players == null) { response.Errors.Add(ServiceErrors.STH_WENT_WRONG); return(response); } response.Object.Players = _mapper.Map <List <PlayerDto> >(players); return(response); }
public ResponseDto <TeamsDto> GetTeamsFromLeague(int leagueId) { var response = new ResponseDto <TeamsDto> { Object = new TeamsDto() }; var teams = _teamRepository.GetTeamsFromLeague(leagueId); if (teams == null) { response.Errors.Add(ServiceErrors.LEAGUE_DOESNT_EXIST); return(response); } response.Object.Teams = _mapper.Map <List <TeamDto> >(teams); return(response); }
public ResponseDto Delete(FicheDeleteDto deleteDto) { ResponseDto responseDto = new ResponseDto(); FicheDeleteBo deleteBo = new FicheDeleteBo() { FicheId = deleteDto.FicheId, Session = Session }; ResponseBo responseBo = ficheBusiness.Delete(deleteBo); responseDto = responseBo.ToResponseDto(); base.SendNotifyWsToList(responseBo.PersonNotifyList); return(responseDto); }
public ResponseDto <LeagueDto> GetLeague(int leagueId) { var response = new ResponseDto <LeagueDto>() { Object = new LeagueDto() }; var league = _leagueRepository.GetById(leagueId); if (league == null) { response.Errors.Add(ServiceErrors.LEAGUE_DOESNT_EXIST); return(response); } response.Object = _mapper.Map <LeagueDto>(league); return(response); }
public ResponseDto UpdateProducts(FicheDto ficheDto) { ResponseDto responseDto = new ResponseDto(); if (ficheDto == null || ficheDto.ProductList == null || ficheDto.ProductList.Count == 0) { responseDto.IsSuccess = false; responseDto.Message = Business.Stc.GetDicValue("xNoProduct", Session.RealPerson.LanguageId); return(responseDto); } FicheBo ficheBo = new FicheBo() { DebtPersonId = ficheDto.DebtPersonId, CreditPersonId = ficheDto.CreditPersonId, CurrencyId = ficheDto.CurrencyId, // We do not need other fields. Session = Session }; ficheBo.ProductList = (from x in ficheDto.ProductList //where !x.IsDeleted select new FicheProductBo { Id = x.Id, ProductId = x.ProductId, Quantity = x.Quantity, UnitPrice = x.UnitPrice, DiscountRate = x.DiscountRate, DiscountTotal = x.DiscountTotal, VatRate = x.VatRate, Notes = x.Notes, IsDeleted = x.IsDeleted }).ToList(); ResponseBo responseBo = ficheProductBusiness.UpdateProducts(ficheBo); responseDto = responseBo.ToResponseDto(); return(responseDto); }
public ResponseDto <User> Authenticate([FromBody] User userParam) { ResponseDto <User> response = new ResponseDto <User>(_commonResource); try { response.Data = _userService.Authenticate(userParam.Email, userParam.Password); if (response.Data == null) { response.IsSuccess = false; response.Message = _commonResource.InvalidUser; } return(response); } catch (Exception ex) { return(response.HandleException(response)); } }
public ActionResult <SubCategoryDto> CreateSubCategory([FromBody] SubCategoryDto subCategory) { subCategory.CategoryId = subCategory.Category.Id; subCategory.Category = null; var subCategoryDto = _subCategoryService.CreateSubCategory(subCategory); if (subCategoryDto == null) { List <string> errorMessage = new List <string>(); errorMessage.Add("Đã phát sinh lỗi, vui lòng thử lại"); return(BadRequest(new ResponseDto(errorMessage, 500, subCategoryDto))); } List <string> successMessage = new List <string>(); successMessage.Add("Thêm thông tin thành công"); var responseDto = new ResponseDto(successMessage, 200, subCategoryDto); return(Ok(responseDto)); }
/// <summary> /// This method is used to return a response data transfer object /// </summary> /// <param name="data">Serialized data to be sent as response</param> /// <returns>Object of ResponseDto</returns> public static ResponseDto ReturnResponse(string data, List <Microsoft.AspNetCore.Mvc.ModelBinding.ModelError> error) { var response = new ResponseDto { Code = error.Count > 0 ? Common.ERROR_CODE : Common.SUCCESS_CODE, Data = new Data { Response = new Response() { ReasonCode = error.Count > 0 ? Common.FAIL_VAL : Common.SUCCESS_VAL, ReasonText = error.Count > 0 ? Common.FAIL : Common.SUCCESS, DataList = data, Error = string.Join("; ", error) } } }; return(response); }
public async Task <IActionResult> Delete(List <int> ids) { var response = new ResponseDto <int>(); try { _context.UserId = User.FindFirstValue(ClaimTypes.NameIdentifier); var campaigns = await _context.Campaign.Where(i => ids.Contains(i.Id)).ToListAsync(); _context.Campaign.RemoveRange(campaigns); response.Data = await _context.SaveChangesAsync(); } catch (Exception ex) { response.ActionState = ActionState.Error; response.Message = ex.Message; } return(Ok(response)); }
public ResponseDto Has(PersonRelationHasCriteriaDto criteriaDto) { ResponseDto responseDto = new ResponseDto(); PersonRelationHasCriteriaBo criteriaBo = new PersonRelationHasCriteriaBo() { RelationTypeId = criteriaDto.RelationTypeId, PersonId1 = criteriaDto.PersonId1, PersonId2 = criteriaDto.PersonId2, Session = Session }; ResponseBo responseBo = personRelationBusiness.Has(criteriaBo); responseDto = responseBo.ToResponseDto(); return(responseDto); }
public async Task <ResponseDto <Customer> > SetCustomerStatus(int customerId, CustomerStatus customerStatus) { var customer = await _dbContext.Customers.FindAsync(customerId); if (customer == null) { var errorDto = new ErrorDto("The customer was not found."); var errorResponse = new ResponseDto <Customer>(errorDto); return(errorResponse); } customer.Status = customerStatus; await _dbContext.SaveChangesAsync(); var responseDto = new ResponseDto <Customer>(customer); return(responseDto); }
public IHttpActionResult GetFolder(string path = null) { DirectoryInfo di; if (path != null) di = new DirectoryInfo(path); else { var drives = new ResponseDto<DriveDto[]>() { Success = true, Result = DriveDto.AllDrives(DriveInfo.GetDrives()) }; return Ok(drives); } if (!di.Exists) { return Ok(ResponseDto<FolderDto>.CreateMessage(MessageEnum.Directory, false)); } var response = new ResponseDto<FolderDto>() { Success = true, Result = FolderDto.CreateFromDirectoryInfo(di) }; return Ok(response); }
public ResponseDto Delete(BasketDeleteDto deleteDto) { ResponseDto responseDto = new ResponseDto(); BasketDeleteBo deleteBo = new BasketDeleteBo() { BasketId = deleteDto.BasketId, Session = Session }; ResponseBo responseBo = basketBusiness.Delete(deleteBo); responseDto = responseBo.ToResponseDto(); base.SendNotifyWsToList(responseBo.PersonNotifyList); return(responseDto); }
public IActionResult PostLead([FromBody] LeadDto leadDto) { var response = new ResponseDto { Metodo = nameof(PostLead) }; try { _leadService.SaveLead(leadDto); response.Resutado = ResultadoResponse.Sucesso; return(Created("", response)); } catch (UnprocessableEntityException e) { response.Resutado = ResultadoResponse.Erro; response.Payload = new { message = e.Message }; return(UnprocessableEntity(response)); } }
public async Task <ResponseDto> Get() { var resp = new ResponseDto(); try { var employees = await _mediator.Send(new GetAllEmployee()); resp.Success = true; resp.Data = employees; } catch (Exception ex) { resp.Success = false; resp.Message = ex.Message; } return(resp); }