public List <TurnModel> GetModel(int id, int month, int year) { var emp = services.GetById(id); var list = new List <TurnModel>(); foreach (var item in horarioServices.ListarHorariosDeEmpleado(id, month, year)) { var n = new TurnModel(); n.EmployeeId = emp.Id; n.Name = emp.Name + " " + emp.Surname; n.CheckIn = item.StartlHour; n.CheckOut = item.FinishHour; n.Price = emp.Price; list.Add(n); } if (list.Count == 0) { list.Add(new TurnModel { EmployeeId = emp.Id, Name = emp.Name + " " + emp.Surname, CheckIn = null, CheckOut = null, Price = emp.Price }); } return(list); }
public List <TurnModel> GetListModel(int turn) { var list = new List <TurnModel>(); var listEmp = employeeServices.ListarPorTurno(turn); var a = horarioServices.ListarPorTurno(turn); foreach (var e in listEmp) { var model = new TurnModel(); model.EmployeeId = e.Id; model.Name = e.Name + " " + e.Surname; if (a.FirstOrDefault(c => c.EmployeeId == e.Id) != null) { model.CheckIn = a.FirstOrDefault(c => c.EmployeeId == e.Id).StartlHour; model.CheckOut = a.FirstOrDefault(c => c.EmployeeId == e.Id).FinishHour; } else { model.CheckIn = null; model.CheckOut = null; } list.Add(model); } return(list); }
public async Task <IActionResult> PutTurnModel([FromRoute] int id, [FromBody] TurnModel turnModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != turnModel.Id) { return(BadRequest()); } _context.Entry(turnModel).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TurnModelExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public List<TurnModel> AllTurns(int playerId) { List<TurnModel> listing = new List<TurnModel>(); using (ADayInTheLifeEntities db = new ADayInTheLifeEntities()) { try { List<Turn> turns = db.Turns.Where(o => o.PlayerId == playerId).ToList(); foreach (Turn t in turns) { TurnModel tm = new TurnModel() { TurnId = t.TurnId, PlayerId = t.PlayerId, GameId = t.GameId, TimeLeft = t.TimeLeft, TurnInGame = t.TurnInGame }; listing.Add(tm); } } catch (Exception e) { //TODO: Log this } } return listing; }
public string GetModelString() { if (HasModel()) { return(TurnModel.ToString()); } else { return("N/A"); } }
public (double speed, double turn) Predict(Data data) { if (HasModel()) { var turn = (Turn)TurnModel.PredictValue(data); return(Motor.Speed, Data.DirectionToTurn(turn)); } else { return(0, 0); } }
public async Task <TurnResult> Move(string sessionId, DirectionEnum direction, int acceleration) { var uri = $"{ServerName}/raceapi/race/{sessionId}"; var turnModel = new TurnModel(direction, acceleration); var response = await client.SendAsync(CreateHttpRequest(uri, HttpMethod.Put, turnModel.ToJson())); var turnResultJson = await response.Content.ReadAsStringAsync(); var turnResult = JsonConvert.DeserializeObject <TurnResult>(turnResultJson); return(turnResult); }
public IActionResult MakeTurn([FromBody] TurnModel turn) { (DurakPresenter game, int playerId) = GetPlayerData(); try { game.Turn(playerId, turn.Card, turn.Target); return(Ok()); } catch (GameException ex) { return(BadRequest(ex.Message)); } }
private void ReceiveTurn(TurnModel model) { if (model == null) { DialogBox.Show("Erreur lors de la communication"); return; } paint = false; partieActuelle = model.PartieActuelle; buttonRemplir.Text = model.BoutonRemplir; buttonRemplir.Visible = model.EtatBoutonRemplir; richTextBox1.Text = model.Historique; paint = true; pictureBox1.Invalidate(); }
public Guid?MakeTurn(string gameId, int x, int y, int value) { //TODO: проверять кто сделал ход. И если пытаются два раза сходить, то агрится. //TODO: проверять не сделан ли ход в уже занятую клетку. if ((value != 0 && value != 1) || x < 0 || x > 2 || y < 0 || y > 2) { return(null); } var turn = new TurnModel(); turn.GameId = gameId == "" ? Guid.NewGuid() : new Guid(gameId); turn.X = x; turn.Y = y; turn.Value = value == 0 ? TicTacToeValue.X : TicTacToeValue.O; DataContext.Turns.Add(turn); DataContext.SaveChanges(); return(turn.GameId); }
/// <summary> /// Convierte los datos del turno /// </summary> private MovementTurnModel ConvertTurn(TurnModel turn) { MovementTurnModel.TurnType ConvertTurnType(TurnModel.TurnType type) { switch (type) { case TurnModel.TurnType.Black: return(MovementTurnModel.TurnType.Black); case TurnModel.TurnType.White: return(MovementTurnModel.TurnType.White); default: return(MovementTurnModel.TurnType.End); } } return(new MovementTurnModel(turn.Number, ConvertTurnType(turn.Type))); }
public async Task <IActionResult> PostTurnModel([FromBody] LastTurns model) { try { var turnModel = new TurnModel() { // CreatedDate = model.CreatedDate.Value, TurnNumber = model.TurnNumber.ToString(), Location = $"{(model.Status==Status.Admitted? "پذیرش" : model.Doctor.RoomNumber)}", DocName = model.Doctor.DisplayName ?? $"{model.Doctor.Name} {model.Doctor.Family}", Vip = model.Vip, TrackingNumber = model.TrackingNumber }; if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.Turns.Add(turnModel); await _context.SaveChangesAsync(); await _hubContext.Clients.All.SendAsync("NewTurn", turnModel); return(Ok(new SignageResponse() { StatusCode = true, })); } catch (Exception e) { return(Ok(new SignageResponse() { StatusCode = false, Message = new List <string>() { e.ToString() } })); } // return CreatedAtAction("GetTurnModel", new { id = turnModel.Id }, turnModel); }
/** * <summary>Méthode à appeler à chaque changement de tour</summary> */ public async void ChangeTurn() { TurnModel model = new TurnModel { PartieActuelle = partieActuelle, BoutonRemplir = buttonRemplir.Text, EtatBoutonRemplir = buttonRemplir.Visible, Historique = richTextBox1.Text }; if (_tcpConnexion.Server != null) // si on est le serveur { await _tcpConnexion.Server.SendAsync(model); await WaitDataServer(); } else { await _tcpConnexion.Client.SendAsync(model); await WaitDataClient(); } }
/// <summary> /// Get Next First Available Turn For Doctor /// </summary> /// <param name="serviceSupplyId">Doctor or any person that supplies a service in shift center</param> /// <param name="centerServiceId">Service that will be supplied in shift center</param> /// <param name="lang">Request Language</param> /// <returns></returns> public async Task <TurnModel> GetNextFirstAvailableTurnAsync(int serviceSupplyId, int centerServiceId, Lang lang) { var serviceSupply = await _serviceSupplyService.GetServiceSupplyByIdAsync(serviceSupplyId); if (serviceSupply == null) { throw new AwroNoreException(Global.Err_DoctorNotFound); } if (!serviceSupply.IsAvailable) { return(null); } var centerService = _servicesService.GetShiftCenterServiceById(centerServiceId); if (centerService == null) { return(null); } var firstTurn = _doctorServiceManager.FindFirstEmptyTimePeriodFromNow(serviceSupply, centerService); if (firstTurn == null) { return(null); } var result = new TurnModel { Date = firstTurn.StartDateTime.Date.ToShortDateString(), DayOfWeek = Utils.ConvertDayOfWeek(firstTurn.StartDateTime.DayOfWeek.ToString()), StartTime = firstTurn.StartDateTime.ToShortTimeString(), EndTime = firstTurn.EndDateTime.ToShortTimeString() }; return(result); }
public TurnModel NewTurn(TurnModel item) { TurnModel ret = new TurnModel(); using (ADayInTheLifeEntities db = new ADayInTheLifeEntities()) { try { Turn t = new Turn() { PlayerId = item.PlayerId, GameId = item.GameId, TimeLeft = item.TimeLeft, TurnInGame = item.TurnInGame }; db.Turns.Add(t); db.SaveChanges(); ret = new TurnModel() { TurnId = t.TurnId, PlayerId = t.PlayerId, GameId = t.GameId, TurnInGame = t.TurnInGame, TimeLeft = t.TimeLeft }; } catch (Exception e) { //TODO: Log this } } return ret; }
public async Task <DoctorDetailsDTO> GetDoctorDetailsAsync(int serviceSupplyId, Lang lang, int?centerServiceId = null, int?offerId = null) { var serviceSupply = await _serviceSupplyService.GetServiceSupplyByIdAsync(serviceSupplyId); if (serviceSupply == null) { throw new AwroNoreException(Global.Err_DoctorNotFound); } var Lng = lang; // Get all places that doctor work var suppliedSerivices = _serviceSupplyService.Table.Where(x => x.PersonId == serviceSupply.PersonId && x.IsAvailable).ToList(); var healthCentersWorkingHours = new List <DoctorCenterModel>(); foreach (var item in suppliedSerivices) { var centerName = ""; var centertype = HealthCenterType.Polyclinic; var centerAddress = ""; if (item.ShiftCenter.IsIndependent) { centerName = Lng == Lang.AR ? item.ShiftCenter.Name_Ar : Lng == Lang.KU ? item.ShiftCenter.Name_Ku : item.ShiftCenter.Name; centertype = HealthCenterType.Polyclinic; centerAddress = Lng == Lang.AR ? $"{item.ShiftCenter.City.Name_Ar}: {item.ShiftCenter.Address_Ar}" : lang == Lang.KU ? $"{item.ShiftCenter.City.Name_Ku}: {item.ShiftCenter.Address_Ku}" : $"{item.ShiftCenter.City.Name}: {item.ShiftCenter.Address}"; } else if (!item.ShiftCenter.IsIndependent && item.ShiftCenter.Clinic.IsIndependent) { centerName = Lng == Lang.AR ? item.ShiftCenter.Clinic.Name_Ar : Lng == Lang.KU ? item.ShiftCenter.Clinic.Name_Ku : item.ShiftCenter.Clinic.Name; centertype = HealthCenterType.Clinic; centerAddress = Lng == Lang.AR ? item.ShiftCenter.Clinic.City.Name_Ar : Lng == Lang.KU ? item.ShiftCenter.Clinic.City.Name_Ku + ": " + item.ShiftCenter.Clinic.Address_Ku : item.ShiftCenter.Clinic.City.Name + ": " + item.ShiftCenter.Clinic.Address; } else { centerName = Lng == Lang.AR ? item.ShiftCenter.Clinic.Hospital.Name_Ar : Lng == Lang.KU ? item.ShiftCenter.Clinic.Hospital.Name_Ku : item.ShiftCenter.Clinic.Hospital.Name; centertype = HealthCenterType.Hospital; centerAddress = Lng == Lang.AR ? $"{item.ShiftCenter.Clinic.Hospital.City.Name_Ar}: {item.ShiftCenter.Clinic.Hospital.Address_Ar}" : Lng == Lang.KU ? $"{item.ShiftCenter.Clinic.Hospital.City.Name_Ku}: {item.ShiftCenter.Clinic.Hospital.Address_Ku}" : $"{item.ShiftCenter.Clinic.Hospital.City.Name}: {item.ShiftCenter.Clinic.Hospital.Address}"; } var WorkingHours = new List <WorkingHourModel>(); var plans = item.UsualSchedulePlans.Where(x => x.ServiceSupplyId == serviceSupplyId).OrderBy(x => x.DayOfWeek).ToList(); foreach (var schedule in plans) { WorkingHours.Add(new WorkingHourModel { DayOfWeek = Utils.ConvertDayOfWeek(schedule.DayOfWeek.ToString()), Shift = schedule.Shift == ScheduleShift.Morning ? Global.Morning : Global.Evening, FromTime = schedule.StartTime, ToTime = schedule.EndTime, Service = Lng == Lang.AR ? schedule.ShiftCenterService?.Service.Name_Ar : Lng == Lang.KU ? schedule.ShiftCenterService?.Service.Name_Ku : schedule.ShiftCenterService?.Service.Name, MaxCount = schedule.MaxCount }); } healthCentersWorkingHours.Add(new DoctorCenterModel { CenterName = centerName, CenterType = centertype, CenterAddress = centerAddress, WorkingHoures = WorkingHours }); } TurnModel firstTurn = null; if (centerServiceId != null) { firstTurn = await GetNextFirstAvailableTurnAsync(serviceSupplyId, centerServiceId.Value, lang); } var firstExpertise = serviceSupply.DoctorExpertises.FirstOrDefault(); var result = new DoctorDetailsDTO { Id = serviceSupply.Id, FullName = lang == Lang.KU ? serviceSupply.Person.FullName_Ku : lang == Lang.AR ? serviceSupply.Person.FullName_Ar : serviceSupply.Person.FullName, Avatar = serviceSupply.Person.RealAvatar, ExpertiseCategory = firstExpertise != null ? lang == Lang.AR ? firstExpertise.Expertise.ExpertiseCategory.Name_Ar : lang == Lang.KU ? firstExpertise.Expertise.ExpertiseCategory.Name_Ku : firstExpertise.Expertise.ExpertiseCategory.Name : "", Address = lang == Lang.KU ? serviceSupply.ShiftCenter.Address_Ku : lang == Lang.AR ? serviceSupply.ShiftCenter.Address_Ar : serviceSupply.ShiftCenter.Address, HasEmptyTurn = firstTurn != null, Province = serviceSupply.ShiftCenter.IsIndependent ? (Lng == Lang.AR ? serviceSupply.ShiftCenter.City.Province.Name_Ar : Lng == Lang.KU ? serviceSupply.ShiftCenter.City.Province.Name_Ku : serviceSupply.ShiftCenter.City.Province.Name) : (Lng == Lang.AR ? serviceSupply.ShiftCenter.Clinic.City.Province.Name_Ar : Lng == Lang.KU ? serviceSupply.ShiftCenter.Clinic.City.Province.Name_Ku : serviceSupply.ShiftCenter.Clinic.City.Province.Name), MedicalCouncilNumber = serviceSupply.ServiceSupplyInfo?.MedicalCouncilNumber, FirstAvailableTurn = firstTurn, Latitude = serviceSupply.ShiftCenter.Location?.Y.ToString(), Longitude = serviceSupply.ShiftCenter.Location?.X.ToString(), Schedules = await GetSchedulesAsync(serviceSupply.Id, lang) }; if (serviceSupply.ShiftCenter.PhoneNumbers != null) { result.Phones = serviceSupply.ShiftCenter.PhoneNumbers.Where(p => p.IsForReserve).Select(x => new ShiftCenterPhoneModel { PhoneNumber = x.PhoneNumber, IsForReserve = x.IsForReserve }).ToList(); } result.Expertises = serviceSupply.DoctorExpertises.Select(x => Lng == Lang.AR ? x.Expertise.Name_Ar : Lng == Lang.KU ? x.Expertise.Name_Ku : x.Expertise.Name).ToList(); result.Description = Lng == Lang.AR ? serviceSupply.ShiftCenter.Description_Ar : Lng == Lang.KU ? serviceSupply.ShiftCenter.Description_Ku : serviceSupply.ShiftCenter.Description; result.Notification = Lng == Lang.AR ? serviceSupply.ShiftCenter.Notification_Ar : Lng == Lang.KU ? serviceSupply.ShiftCenter.Notification_Ku : serviceSupply.ShiftCenter.Notification; result.WorkingCenters = healthCentersWorkingHours; var photosQuery = _dbContext.Attachments.Where(x => x.Owner == FileOwner.SHIFT_CENTER && x.OwnerTableId == serviceSupply.ShiftCenterId && x.FileType == FileType.Image); result.Photos = await photosQuery.Select(x => x.Url).ToListAsync(); result.PhotosThumbs = await photosQuery.Select(x => x.ThumbnailUrl).ToListAsync(); result.Grades = serviceSupply.ServiceSupplyInfo?.DoctorScientificCategories.Select(x => Lng == Lang.AR ? x.ScientificCategory.Name_Ar : Lng == Lang.KU ? x.ScientificCategory.Name_Ku : x.ScientificCategory.Name).ToList(); result.Bio = Lng == Lang.EN ? serviceSupply.ServiceSupplyInfo?.Bio : Lng == Lang.AR ? serviceSupply.ServiceSupplyInfo?.Bio_Ar : serviceSupply.ServiceSupplyInfo?.Bio_Ku; if (offerId != null) { var offer = await _dbContext.Offers.FindAsync(offerId); if (offer != null) { offer.VisitsCount += 1; _dbContext.Attach(offer); _dbContext.Entry(offer).State = EntityState.Modified; _dbContext.Offers.Update(offer); await _dbContext.SaveChangesAsync(); } } return(result); }
/// <summary> /// Lee los movimientos /// </summary> private SentenceBaseModel ReadMovements(IEnumerator <SentenceBaseModel> sentenceEnumerator, SentenceBaseModel previousSentence, List <BaseMovementModel> movements) { SentenceBaseModel sentence = previousSentence; BaseMovementModel lastMovement = null; TurnModel lastTurn = null; // Añade los movimientos do { // Trata la sentencia switch (sentence) { case SentenceTurnNumberModel sentenceTurn: lastMovement = null; lastTurn = new TurnModel(sentenceTurn.Content, TurnModel.TurnType.White); break; case SentenceTurnPlayModel sentencePlay: if (lastTurn == null) { sentence = new SentenceErrorModel($"There is not turn to add the play {sentencePlay.Content}"); } else { // Crea el movimiento lastMovement = new PieceMovementModel(lastTurn, sentencePlay.Content); // Añade el movimiento movements.Add(lastMovement); } break; case SentenceTurnResultModel sentenceResult: if (lastTurn == null) { sentence = new SentenceErrorModel($"There is not turn to add the result {sentenceResult.Content}"); } else { // Crea el movimiento lastMovement = new ResultMovementModel(lastTurn, sentence.Content); // Añade el movimiento movements.Add(lastMovement); } break; case SentenceTurnInformationModel sentenceInformation: if (lastMovement == null) { sentence = new SentenceErrorModel($"There is not movement to add the information {sentenceInformation.Content}"); } else { lastMovement.Info.Add(new InfoMovementModel(sentence.Content)); } break; case SentenceCommentModel sentenceComment: if (lastMovement == null) { sentence = new SentenceErrorModel($"There is not sentence to add the comment {sentenceComment.Content}"); } else { lastMovement.Comments.Add(sentenceComment.Content); } break; case SentenceTurnStartVariationModel sentenceVariation: if (lastMovement == null) { sentence = new SentenceErrorModel("There is not sentence to add a variation"); } else { VariationModel variation = new VariationModel(lastMovement); // Limpia esta sentencia del enumerado sentence = GetNextSentence(sentenceEnumerator); // Añade los comentarios y la información a la variación while (sentence is SentenceTurnInformationModel || sentence is SentenceCommentModel) { // Añade la información de la sentencia switch (sentence) { case SentenceTurnInformationModel sentenceInfo: variation.Info.Add(new InfoMovementModel(sentenceInfo.Content)); break; case SentenceCommentModel sentenceComment: variation.Comments.Add(sentenceComment.Content); break; } // Pasa a la siguiente sentencia sentence = GetNextSentence(sentenceEnumerator); } // Lee los movimientos de la variación sentence = ReadMovements(sentenceEnumerator, sentence, variation.Movements); // Añade la variación a la colección if (variation.Movements.Count > 0) { lastMovement.Variations.Add(variation); } // Pasa a la siguiente sentencia if (!(sentence is SentenceTurnEndVariationModel)) { sentence = new SentenceErrorModel("Can't find the end variation sentence"); } } break; } // Pasa a la siguiente sentencia if (!(sentence is SentenceErrorModel)) { sentence = GetNextSentence(sentenceEnumerator); } }while (!(sentence is SentenceEndModel) && !(sentence is SentenceErrorModel) && !(sentence is SentenceTagModel) && !(sentence is SentenceTurnEndVariationModel)); // Devuelve la última sentencia leída return(sentence); }
public TurnModel TurnById(int playerId, int turnId) { TurnModel ret = null; using (ADayInTheLifeEntities db = new ADayInTheLifeEntities()) { try { Turn t = db.Turns.Where(o => o.PlayerId == playerId && o.TurnId == turnId).FirstOrDefault(); if (t == null) { throw new Exception("Couldn't find that Turn record."); } ret = new TurnModel() { PlayerId = t.PlayerId, GameId = t.GameId, TurnInGame = t.TurnInGame, TimeLeft = t.TimeLeft, TurnId = t.TurnId }; } catch (Exception e) { //TODO: Log This. } } return ret; }