public void ReturnStatusDto_WhenInvokedWithCorrectParameters() { //Arrange var mapperMock = new Mock <IMappingProvider>(); var statusesRepoMock = new Mock <IRepository <Status> >(); var statusService = new StatusesService(mapperMock.Object, statusesRepoMock.Object); var data = new List <Status>() { new Status { Id = 1, Name = "Draft" }, new Status { Id = 2, Name = "Publish" } }; var dataMapper = new StatusDto() { Id = 1, Name = "Draft" }; statusesRepoMock.Setup(x => x.All).Returns(data.AsQueryable()); mapperMock.Setup(m => m.MapTo <StatusDto>(It.IsAny <Status>())).Returns(dataMapper); //Act var statusDto = statusService.GetStatusByName("Draft"); //&Assert Assert.IsNotNull(statusDto); Assert.IsInstanceOfType(statusDto, typeof(StatusDto)); }
public ResponseViewModel Get(int id) { var response = new ResponseViewModel(); var status = _statusDal.GetStatus(p => p.Id == id); if (status == null) { response.IsSuccess = false; response.Message = "Status bulunamadı."; return(response); } var statusDto = new StatusDto() { Id = status.Id, Name = status.Name, CreateDate = status.CreateDate, CreatedBy = status.CreatedBy, ModifyDate = status.ModifyDate, ModifiedBy = status.ModifiedBy, IsDeleted = status.IsDeleted }; response.Data = statusDto; return(response); }
/// <summary> /// Получение списка всех статусов конкретного пациента /// </summary> /// <param name="patientId"></param> /// <returns>Список статусов</returns> public async Task <List <StatusDto> > GetStatusesAsync(int patientId) { var result = await Db.StatusEntities.Where(x => x.PatientId == patientId).OrderBy(x => x.CreatedDate) .Select(status => StatusDto.FromEntity(status)).ToListAsync(); return(result); }
public static Status CreateStatus(StatusDto previousStatusDto, StatusDto newStatusDto) { var result = new Status { StartDate = newStatusDto.CreatedDate, EndDate = DateTime.UtcNow, StatusId = newStatusDto.StatusId, Parameters = new Parameters { IsHospitalized = newStatusDto.Parameters.IsHospitalized, IsWheezing = newStatusDto.Parameters.IsWheezing, Pef = newStatusDto.Parameters.Pef, SpO2 = newStatusDto.Parameters.SpO2 }, PreviousStatus = new Status { StartDate = previousStatusDto.CreatedDate, EndDate = newStatusDto.CreatedDate, StatusId = previousStatusDto.StatusId, Parameters = new Parameters { IsHospitalized = previousStatusDto.Parameters.IsHospitalized, IsWheezing = previousStatusDto.Parameters.IsWheezing, Pef = previousStatusDto.Parameters.Pef, SpO2 = previousStatusDto.Parameters.SpO2 } } }; return(result); }
/// <summary> /// Registers a prospect. /// </summary> /// <param name="prospect">The prospect.</param> /// <returns>Status.</returns> /// <exception cref="System.ArgumentNullException">prospect</exception> public async Task <Status> RegisterProspect(Prospect prospect) { if (prospect == null) { throw new ArgumentNullException("prospect"); } var prospectDto = new ProspectDto { DsrPhone = prospect.DsrPhone, FirstName = prospect.FirstName, LastName = prospect.LastName, Phone = prospect.Phone, Means = prospect.Money, Authority = prospect.Authority, Need = prospect.Need }; Status status = null; StatusDto statusDto = await api.RegisterProspect(prospectDto); if (statusDto != null) { status = new Status { Success = statusDto.Successful, Text = statusDto.ResponseText }; } return(status); }
public void InnokeMapperMapToMethod() { //Arrange var mapperMock = new Mock <IMappingProvider>(); var statusesRepoMock = new Mock <IRepository <Status> >(); var statusService = new StatusesService(mapperMock.Object, statusesRepoMock.Object); var data = new List <Status>() { new Status { Id = 1, Name = "Draft" }, new Status { Id = 2, Name = "Publish" } }; var dataMapper = new StatusDto() { Id = 1, Name = "Draft" }; statusesRepoMock.Setup(x => x.All).Returns(data.AsQueryable()); mapperMock.Setup(m => m.MapTo <StatusDto>(It.IsAny <Status>())).Returns(dataMapper); //Act var statusDto = statusService.GetStatusByName("Draft"); //&Assert mapperMock.Verify(x => x.MapTo <StatusDto>(It.IsAny <Status>()), Times.Once); }
public IList <StatusDto> GetUpdated(int id) { try { var stocksDtos = _unitOfWork.Stocks.GetAllOfInventory(id); var statusDtos = new List <StatusDto>(); foreach (var stocksDto in stocksDtos) { var statusDto = new StatusDto { InventoryId = stocksDto.InventoryId, ProductId = stocksDto.ProductId, Product = stocksDto.Product, ExpQuantity = stocksDto.Quantity }; statusDtos.Add(statusDto); } return(statusDtos); } catch (Exception) { // TODO lav exception throw; } }
public void Initialize(StatusDto statusDto) { Dead = statusDto.Dead; Stunned = statusDto.Stunned; Fleeing = statusDto.Fleeing; Sheltered = statusDto.Sheltered; }
/// <summary> /// Добавление статус пациенту /// </summary> /// <param name="patientId"></param> /// <param name="parameters"></param> /// <returns>Новый статус пациента</returns> public async Task <StatusDto> AddStatusAsync(int patientId, ParametersDto parameters) { var patient = await Db.PatientEntities.FirstOrDefaultAsync(x => x.PatientId == patientId); var newStatus = new StatusEntity { PatientId = patientId, PreviousStatusId = patient.StatusId, IsHospitalized = parameters.IsHospitalized, IsWheezing = parameters.IsWheezing, Pef = parameters.Pef, SpO2 = parameters.SpO2, CreatedDate = DateTime.UtcNow }; Db.StatusEntities.Add(newStatus); Db.SaveChanges(); patient.StatusId = newStatus.StatusId; await Db.SaveChangesAsync(); var result = StatusDto.FromEntity(newStatus); return(result); }
public IActionResult AddStatuses(StatusDto statusDto) { var status = _mapper.Map <Status>(statusDto); _statusService.Add(status); return(Ok()); }
public StatusDto GetStatusCount() { try { var declarations = DeclarationDal.GetAllDeclarations(); var statusDto = new StatusDto(); foreach (var declaration in declarations) { if (declaration.Status == "Rejected") { statusDto.Rejected++; } else if (declaration.Status == "Cleared") { statusDto.Cleared++; } else { statusDto.Processing++; } } return(statusDto); } catch { throw; } }
public async Task <PaymentDto> StatusAsync(StatusDto input) { var httpRequest = BuildRequest(StatusUrl, input, Method.POST); var response = await ExecuteRequestAsync <Response <PaymentDto> >(httpRequest); return(response.Result); }
public IHttpActionResult CreateStatus(StatusApiModel model) { var time = DateTime.Now; var user = User.Identity.Name; var modelDto = new List <StatusDto>(); for (int i = 0; i < model.ProductIds.Count; i++) { var statusDto = new StatusDto { InventoryId = model.InventoryId, ProductId = model.ProductIds[i], ExpQuantity = model.ExpQuantities[i], CurQuantity = model.CurQuantities[i], Difference = model.Differences[i], IsStarted = model.IsStarted, ByUser = user, Updated = time }; modelDto.Add(statusDto); } _statusService.Create(modelDto); return(Ok()); }
/// <summary> /// Create Output /// </summary> /// <param name="httpStatusCode"></param> /// <param name="exception"></param> public OutputDto(HttpStatusCode httpStatusCode, string exception) { Status = new StatusDto { Exception = exception, Code = httpStatusCode }; }
public StatusDto MapToStatusDto(SqlDataReader sqlDataReader) { StatusDto statusDto = new StatusDto(); statusDto.Id = sqlDataReader["Id"].ToInteger(); return(statusDto); }
public IActionResult UpdateStatus(StatusDto statusDto, [FromRoute] int id) { var status = _mapper.Map <Status>(statusDto); status.Id = id; _statusService.Update(status); return(Ok()); }
public void ChangeStatus(StatusDto input) { var query = _BrokerSubMasterRepository.GetAll().Where(c => c.Id == input.Id && c.TenantID == _abpSession.TenantId) .FirstOrDefault(); query.IsActive = input.Status; _BrokerSubMasterRepository.Update(query); }
public ActionResult PostStatus([FromBody] StatusDto statusDto) { var response = _service.Add(statusDto); _service.Save(response); return(new OkObjectResult(response["Output"])); }
/// <summary> /// Получение определенного статуса определенного пациента /// </summary> /// <param name="patientId"></param> /// <param name="statusId"></param> /// <returns>Статус пациента</returns> public async Task <StatusDto> GetStatusAsync(int patientId, int statusId) { var status = await Db.StatusEntities.FirstOrDefaultAsync(x => x.PatientId == patientId && x.StatusId == statusId); var result = StatusDto.FromEntity(status); return(result); }
public async Task <StatusDto> GetStatusAsync(int id, CancellationToken ct) { Status statusEntity = await _uow.Status.GetStatusAsync(id, ct); StatusDto statusDto = _mapper.Mapper.Map <StatusDto>(statusEntity); return(statusDto); }
public IActionResult Status([FromQuery] string Key, [FromQuery] string Timestamp, [FromQuery] string Signature) { var sw = new Stopwatch(); sw.Start(); decimal elapsedTime = 0; StatusDto status = new StatusDto(); _logger.LogInformation(LoggingEvents.GET_STATUS, $"Status request parameters: {Key}, {Timestamp}, {Signature}"); //if (string.IsNullOrEmpty(Key) || string.IsNullOrEmpty(Timestamp) || string.IsNullOrEmpty(Signature)) //{ // return Unauthorized(); //} try { var result = _dbcontext.Activity.Count(); status.SQLAvailable = true; } catch (Exception ex) { _logger.LogError(LoggingEvents.GET_STATUS_EXCEPTION, $"Get Status error: " + ex.Message); status.SQLAvailable = false; status.Message = ex.Message; } try { int errorNumber = 0; string errorMessage = string.Empty; bool success = eConn.CheckeConnectVendor(_config.GPCompanyDB, _config.eConnectTestVendorID, ref errorNumber, ref errorMessage); //bool success = eConn.SaleTransactionEntry(_config.GPCompanyDB, _config.eConnectTestVendorID, ref errorNumber, ref errorMessage); //bool success = eConn.DeleteSaleTransactionEntry(_config.GPCompanyDB, _config.eConnectTestVendorID, ref errorNumber, ref errorMessage); //bool success = eConn.UpdateSaleTransactionEntry(_config.GPCompanyDB, _config.eConnectTestVendorID, ref errorNumber, ref errorMessage); status.eConnectAvailable = success; if (!String.IsNullOrEmpty(status.Message)) { status.Message += Environment.NewLine; } status.Message += errorMessage; } catch (Exception ex) { _logger.LogError(LoggingEvents.GET_STATUS_EXCEPTION, $"Get Status eConnect exception: " + ex.Message); status.eConnectAvailable = false; } sw.Stop(); elapsedTime = Convert.ToDecimal(sw.ElapsedMilliseconds); status.Elapsed = elapsedTime.ToString(); _logger.LogInformation(LoggingEvents.GET_STATUS, "Status call completed in " + status.Elapsed + "ms"); return(Ok(status)); }
/// <summary> /// This method recieves an StatusDto model that we expect to delete based off of the primary key /// </summary> /// <param name="oldStatus"></param> /// <returns>Task<bool></returns> public async Task <bool> DeleteStatus(StatusDto oldStatus) { Status statusVnM = new Status(); //validate the incoming DTO first before converting into DAO //STILL NEED TO VALIDATE return(await graceService.DeleteStatusAsync(statusVnM.MapToDao(oldStatus))); }
private static void StatusListener_Received(object sender, StatusDto e) { using (var writer = File.AppendText(_statusesPath)) { writer.WriteLine("Status Received on: {0}", DateTime.Now); writer.WriteLine("Service name: {0}", e.ServiceName); writer.WriteLine("Status: {0}", e.Value); } }
public static Status ToBd(this StatusDto statusDto) { var status = new Status(); status.Id = statusDto.Id; status.Descricao = statusDto.Descricao; return(status); }
public async Task UpsertAsync(StatusKeys key, string value) { StatusDto dto = new StatusDto { Key = key, Value = value, }; await UpsertAsync(dto); }
/// <summary> /// Create Output /// </summary> /// <param name="content"></param> public OutputDto(T content) { Content = content; Status = new StatusDto { Message = HttpStatusCode.OK.ToString(), Code = HttpStatusCode.OK }; }
public async Task <bool> Add(StatusDto statusDto) { var status = _mapper.Map <AvailabilityStatus>(statusDto); await _context.AddAsync(status); await _context.SaveChangesAsync(); return(true); }
public static StatusDto ToApp(this Status status) { var statusDto = new StatusDto(); statusDto.Id = status.Id; statusDto.Descricao = status.Descricao; return(statusDto); }
/// <summary> /// Initialize dependencies /// </summary> public UnitTest() { _jwtWrapper = new JwtWrapper(); _objectToEncode = new StatusDto { Message = "Space Dust", Code = HttpStatusCode.OK }; }
public static StatusViewModel MapToViewModel(this StatusDto statusDto) { return(statusDto == null ? null : new StatusViewModel() { Id = statusDto.Id, Title = statusDto.Title }); }