public async Task <IActionResult> Edit(int id, [Bind("PeopleID,PeopleName,PeopleFrom,PeopleGende,PeopleDateOfBirth,PeopleAddress,PeoplePIDNumber,PeoplePIDDate,PeoplePIDPlace,PeoplePIDValidUntil,JoinDate,PeopleImagePath")] PeopleData peopleData) { if (id != peopleData.PeopleID) { return(NotFound()); } if (ModelState.IsValid) { using (var httpClient = _api.Initial()) { StringContent content = new StringContent(JsonConvert.SerializeObject(peopleData), Encoding.UTF8, "application/json"); //string endpoint = apiBaseUrl + "/login"; using (var response = await httpClient.PutAsync("api/Peoples/" + id, content)) { if (response.StatusCode == System.Net.HttpStatusCode.OK) { string apiResonse = await response.Content.ReadAsStringAsync(); peopleData = JsonConvert.DeserializeObject <PeopleData>(apiResonse); } else { ViewBag.StatusCode = response.StatusCode; } } } } //return View(peopleData); return(View()); //Index }
// GET: PeopleDatas/Details/5 public async Task <IActionResult> Details(int?id) { var peopleDetail = new PeopleData(); if (id == null) { return(NotFound()); } using (var httpClient = _api.Initial()) { using (var response = await httpClient.GetAsync("api/Peoples/" + id)) { if (response.StatusCode == System.Net.HttpStatusCode.OK) { string apiResonse = await response.Content.ReadAsStringAsync(); peopleDetail = JsonConvert.DeserializeObject <PeopleData>(apiResonse); } else { ViewBag.StatusCode = response.StatusCode; } } } return(View(peopleDetail)); }
public string verticalDrawName;//立绘图片 TODO后续改成配表 /// <summary> /// TODO通过配表的Setting创建新People(PeopleData后续要改成PeopleSetting) /// </summary> /// <param name="peopleData"></param> public People(PeopleData peopleData) { this.name = peopleData.name; this.gender = peopleData.gender; if (peopleData.name == "毛鹏程") { isPlayer = true; } if (gender == Gender.Male) { int val = RandomManager.Next(1, 4); verticalDrawName = "boy" + val; } else { int val = RandomManager.Next(1, 8); verticalDrawName = "girl" + val; } PeopleProtoData peopleProtoData = new PeopleProtoData(); peopleProtoData.Achievement = new Achievement(); peopleProtoData.OnlyId = ConstantVal.SetId; peopleProtoData.Name = peopleData.name; peopleProtoData.Gender = (int)peopleData.gender; peopleProtoData.IsPlayer = isPlayer; peopleProtoData.ExamBattleCurLevel = 1; CreateNewPropertyData(peopleProtoData); RoleManager.Instance.InitPeopleSocializationProperty(peopleProtoData); this.protoData = peopleProtoData; }
public void Load() { PeopleData pd_ = DataController.GetPeopleData(); PersonBehavior newPerson; int maxID = -1, maxfamID = -1; foreach (PersonData p in pd_.people) { if (p.ID > maxID) { maxID = p.ID; } if (p.familyID > maxfamID) { maxfamID = p.familyID; } newPerson = PlacePerson(sc.GetMap().FindSectionByID(p.initSectionID), p.initPos); newPerson.SetupFromData(sc.GetGraph().FindNodeByID(p.initNodeID), p.ID, p.priority, p.age, p.types, p.speed, p.firstName, p.familyID, p.dependent, p.manualDependencies, p.tutorID); } currentPersonID = maxID + 1; currentFamilyID = maxfamID + 1; foreach (PersonBehavior p2 in people) { p2.SetDependenciesFromData(p2.GetTutorID()); } }
public void Load() { BalancingData = new BalancingData(); PeopleData = new PeopleData(); BalancingData.Load(BalancingDataCSV); PeopleData.Load(PeopleDataCSV); }
public async Task <IActionResult> Create([Bind("ID,Nombre,Apellido,Sexo,Address,Cargo,Celular,Sueldo,FechaNacimiento,FechaIngreso,Image")] PeopleData model, IFormFile img) { var user = await _userManager.GetUserAsync(User); if (user == null) { return(RedirectToAction(nameof(AccountController.Login), "Account")); // throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'."); } if (ModelState.IsValid) { var newEmpleado = new PeopleData(); var profileImage = img; if (profileImage != null) { var path = Path.Combine( Directory.GetCurrentDirectory(), "wwwroot/images", profileImage.FileName); using (var stream = new FileStream(path, FileMode.Create)) { await profileImage.CopyToAsync(stream); } newEmpleado.Image = profileImage.FileName; } else { var path = "user.png"; newEmpleado.Image = path; } newEmpleado.Address = model.Address; newEmpleado.Apellido = model.Apellido; newEmpleado.Cargo = model.Cargo; newEmpleado.Celular = model.Celular; newEmpleado.FechaIngreso = model.FechaIngreso; newEmpleado.FechaNacimiento = model.FechaNacimiento; newEmpleado.Nombre = model.Nombre; newEmpleado.Sexo = model.Sexo; newEmpleado.Sueldo = model.Sueldo; var notification = new Notifications(); TempData["sms"] = "Se agregó al empleado " + model.Nombre + " exitosamente a la lista de empleados."; ViewBag.sms = TempData["sms"]; notification.Detalle = ViewBag.sms; notification.Section = "Empleados"; notification.Tipo = "check"; notification.Time = DateTime.Now; notification = _empleadosData.AddNotification(notification); newEmpleado = _empleadosData.Add(newEmpleado); return(RedirectToAction(nameof(Index))); } else { return(View(model)); } }
public async Task <IActionResult> Create([Bind("ID,Nombre,Apellido,Sexo,Address,Cargo,Celular,Sueldo,FechaNacimiento,FechaIngreso,Image")] PeopleDataViewModel model, IFormFile img) { var user = await _userManager.GetUserAsync(User); if (user == null) { return(RedirectToAction(nameof(AccountController.Login), "Account")); // throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'."); } if (ModelState.IsValid) { var newEmpleado = new PeopleData(); var profileImage = model.Image; if (profileImage != null) { var path = Path.Combine( Directory.GetCurrentDirectory(), "wwwroot/images", profileImage.FileName); using (var stream = new FileStream(path, FileMode.Create)) { await profileImage.CopyToAsync(stream); } newEmpleado.Image = profileImage.FileName; } else { var path = "user.png"; newEmpleado.Image = path; } newEmpleado.Address = model.Address; newEmpleado.Apellido = model.Apellido; newEmpleado.Cargo = model.Cargo; newEmpleado.Celular = model.Celular; newEmpleado.FechaIngreso = model.FechaIngreso; newEmpleado.FechaNacimiento = model.FechaNacimiento; newEmpleado.Nombre = model.Nombre; newEmpleado.Sexo = model.Sexo; newEmpleado.Sueldo = model.Sueldo; newEmpleado = _empleadosData.Add(newEmpleado); return(RedirectToAction(nameof(Index))); } else { return(View(model)); } }
protected override void Seed(PagedTableAspNetMvc.Models.ExampleDataContext context) { var records = PeopleData .Split('\n') .Select(x => { var p = x.Split(','); return(new Person { FullName = p[0], Phone = p[1], Email = p[2] }); }); context.People.AddOrUpdate(x => x.FullName, records.ToArray()); }
public async Task <IActionResult> Create(PeopleData peopleData) { HttpClient client = _api.Initial(); //HTTP POST PeopleData newAdded = new PeopleData(); using (var response = await client.PostAsJsonAsync <PeopleData>("api/Peoples", peopleData)) { string apiResponse = await response.Content.ReadAsStringAsync(); newAdded = JsonConvert.DeserializeObject <PeopleData>(apiResponse); } return(View("Edit", newAdded)); }
public async Task Should_not_find_a_unregisted_person_by_id(long id) { var mockRepository = new Mock <IReadPeopleRepository>(); mockRepository.Setup(x => x.FindAsync(It.IsAny <object[]>(), It.IsAny <CancellationToken>())) .Returns <object[], CancellationToken>((o, c) => { return(Task.FromResult(PeopleData.GetSeedData().FirstOrDefault(x => x.PersonId == (long)o[0]))); }); var validator = new PeopleFindValidators(mockRepository.Object); Func <Task> act = async() => await validator.ValidateAndThrowAsync(new PersonFindModel { PersonId = id }, CancellationToken.None); act.Should().Throw <ValidationException>(); }
private static void Fetch(string url) { using (WebClient wc = new WebClient()) { var data = wc.DownloadString(url); PeopleData pd = JsonConvert.DeserializeObject <PeopleData>(data); foreach (PersonalData person in pd.Results) { output.Add(person); } if (!String.IsNullOrEmpty(pd.Next)) // NOT { Fetch(pd.Next); } } }
public void AddMorePeople(string data) { PeopleData peopleData = new PeopleData(); MemoryStream ms = new MemoryStream(Encoding.Unicode.GetBytes(data)); System.Runtime.Serialization.Json.DataContractJsonSerializer serializer = new System.Runtime.Serialization.Json.DataContractJsonSerializer(peopleData.GetType()); peopleData = serializer.ReadObject(ms) as PeopleData; ms.Close(); gspivotviewer.ItemsSource = new ObservableCollection<Person>(); var coll = gspivotviewer.ItemsSource as ObservableCollection<Person>; foreach (Person person in peopleData.data) { coll.Add(person); } }
public async Task Should_find_a_person_by_id(long id) { var mockRepository = new Mock <IReadPeopleRepository>(); mockRepository.Setup(m => m.SearchAsync(It.IsAny <ISpecification <Person> >(), It.IsAny <Expression <Func <Person, ICollection <SocialAccount> > > >(), It.IsAny <CancellationToken>())) .Returns <ISpecification <Person>, Expression <Func <Person, ICollection <SocialAccount> > >, CancellationToken>((p, e, c) => { var id = GetSearchIdFromExpression(p); return(Task.FromResult(PeopleData.GetSeedData().Where(x => x.PersonId == id))); }); var mockValidator = new Mock <IPeopleFindValidators>(); mockValidator.Setup(m => m.ValidateAndThrowAsync(It.IsAny <PersonFindModel>(), It.IsAny <CancellationToken>())) .Returns(Task.FromResult(true)); var queryPeople = new PeopleQuery(mockRepository.Object, mockValidator.Object); var person = await queryPeople.GetByIdAsync(id, CancellationToken.None); person.Should().NotBeNull(); }
public IEnumerator SendResponse() { WWWForm form = new WWWForm(); form.AddField("name", ServerData.GlobalUser); //добавление полей к форме отправления form.AddField("type", "people"); //добавление полей к форме отправления UnityWebRequest www = UnityWebRequest.Post(postURL, form); yield return(www.SendWebRequest());//ждем if (www.isNetworkError || www.isHttpError) { Debug.Log("Error: " + www.error); yield break; } else { inData = JsonUtility.FromJson <PeopleData>(www.downloadHandler.text); PeopleDataSave(); } yield return(new WaitForSeconds(0.1f)); }
public static ScriptablePeopleAll MakePeopleData(int count) { ScriptablePeopleAll obj = ScriptableObject.CreateInstance <ScriptablePeopleAll>(); for (int i = 0; i < count; ++i) { PeopleData p = new PeopleData(); p.m_staticStatistic.name = "name" + i; p.m_staticStatistic.id = i; p.m_staticStatistic.MoveSpeed = 3; p.m_staticStatistic.Power = 0.01f; p.CalStatistic(); obj.m_data.Add(p); } #if UnityEditor UnityEditor.AssetDatabase.CreateAsset(obj, "Assets/Resources/Data/d_people_all.asset"); UnityEditor.AssetDatabase.SaveAssets(); UnityEditor.AssetDatabase.Refresh(); #endif return(obj); }
public override void Update() { m_obj.m_data.cur_madness = Time.fixedTime % 1; Vector3 flee_dir = Vector3.zero; Vector3 cur_pos = m_obj.gameObject.transform.position; foreach (GameObject o in m_vec_target) { PeopleData target_data = o.GetComponent <People>().m_data; flee_dir += (cur_pos - o.transform.position) * target_data.cur_horrible; } flee_dir.y = 0; flee_dir.Normalize(); flee_dir *= m_obj.m_data.cur_speed; //Vector3 old_vel = m_obj.rb.velocity; //old_vel.x = flee_dir.x; //old_vel.z = flee_dir.z; //m_obj.rb.velocity = old_vel; m_obj.rb.AddForce(flee_dir); }
public async Task <IActionResult> Edit(int id, [Bind("ID,Nombre,Apellido,Sexo,Address,Cargo,Celular,Sueldo,FechaNacimiento,FechaIngreso,Image")] PeopleData peopleData, IFormFile img) { var user = await _userManager.GetUserAsync(User); if (user == null) { return(RedirectToAction(nameof(AccountController.Login), "Account")); // throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'."); } if (id != peopleData.ID) { return(NotFound()); } if (img == null) { if (peopleData != null) { _context.Update(peopleData); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } } else { var image = img.FileName; //if (ModelState.IsValid) //{ try { if (image != null) { var path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/images", img.FileName); using (var stream = new FileStream(path, FileMode.Create)) { await img.CopyToAsync(stream); } peopleData.Image = img.FileName; _context.Update(peopleData); await _context.SaveChangesAsync(); } } catch (DbUpdateConcurrencyException) { if (!PeopleDataExists(peopleData.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(peopleData)); }
public static void LoadPeople() { peopleData = LoadData <PeopleData>(dataPeopleFilename); }
public async Task <IActionResult> Edit(int id, [Bind("ID,Nombre,Apellido,Sexo,Address,Cargo,Celular,Sueldo,FechaNacimiento,FechaIngreso,Image")] PeopleData peopleData, IFormFile img) { var user = await _userManager.GetUserAsync(User); if (user == null) { return(RedirectToAction(nameof(AccountController.Login), "Account")); } if (id != peopleData.ID) { return(NotFound()); } if (img == null) { if (peopleData != null) { var notification = new Notifications(); TempData["sms"] = "Los cambios se han guardado con satisfacción!"; ViewBag.sms = TempData["sms"]; notification.Detalle = ViewBag.sms; notification.Section = "Empleados"; notification.Tipo = "check"; notification.Time = DateTime.Now; notification = _empleadosData.AddNotification(notification); _context.Update(peopleData); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } } else { var image = img.FileName; //if (ModelState.IsValid) //{ try { if (image != null) { var path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/images", img.FileName); using (var stream = new FileStream(path, FileMode.Create)) { await img.CopyToAsync(stream); } var notification = new Notifications(); peopleData.Image = img.FileName; TempData["sms"] = "Los cambios se han realizado satisfactoriamente!"; ViewBag.sms = TempData["sms"]; notification.Detalle = ViewBag.sms; notification.Section = "Empleados"; notification.Tipo = "check"; notification.Time = DateTime.Now; notification = _empleadosData.AddNotification(notification); _context.Update(peopleData); await _context.SaveChangesAsync(); } } catch (DbUpdateConcurrencyException) { if (!PeopleDataExists(peopleData.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(peopleData)); }
public PeopleData Add(PeopleData empleado) { _context.PeopleData.Add(empleado); _context.SaveChanges(); return(empleado); }
public void PassPeopleData(string data) { PeopleData peopleData = new PeopleData(); MemoryStream ms = new MemoryStream(Encoding.Unicode.GetBytes(data)); System.Runtime.Serialization.Json.DataContractJsonSerializer serializer = new System.Runtime.Serialization.Json.DataContractJsonSerializer(peopleData.GetType()); peopleData = serializer.ReadObject(ms) as PeopleData; ms.Close(); gspivotviewer.ItemAdornerStyle = this.Resources["peopleAdorner"] as Style; gspivotviewer.PivotProperties.Clear(); gspivotviewer.PivotProperties = new List<PivotViewerProperty>() { new PivotViewerStringProperty() { Binding = new Binding("name"), Id = "Name", Options = PivotViewerPropertyOptions.CanFilter | PivotViewerPropertyOptions.CanSearchText }, new PivotViewerStringProperty() { Binding = new Binding("employee"), Id = "Employee", Options = PivotViewerPropertyOptions.CanFilter | PivotViewerPropertyOptions.CanSearchText }, new PivotViewerStringProperty() { Binding = new Binding("champion"), Id = "Champion", Options = PivotViewerPropertyOptions.CanFilter | PivotViewerPropertyOptions.CanSearchText }, new PivotViewerStringProperty() { Binding = new Binding("tagline"), Id = "Tagline", Options = PivotViewerPropertyOptions.CanFilter | PivotViewerPropertyOptions.CanSearchText }, new PivotViewerStringProperty() { Binding = new Binding("at_sfn"), Id = "URL", Options = PivotViewerPropertyOptions.CanFilter | PivotViewerPropertyOptions.CanSearchText } }; gspivotviewer.ItemTemplates = new PivotViewerItemTemplateCollection(); gspivotviewer.ItemTemplates.Add((PivotViewerItemTemplate)Resources["peopleTemplate"]); gspivotviewer.ItemsSource = new ObservableCollection<Person>(); var coll = gspivotviewer.ItemsSource as ObservableCollection<Person>; coll.Clear(); foreach (Person person in peopleData.data) { coll.Add(person); } if (peopleData.total > 50) { for (int counter = 1; counter < 4; counter++) { if (peopleData.total > counter * 50) { string apiToCall = "/people.json?filter=visitor&limit=50&page=" + counter + "&callback=handlerMorePeople"; HtmlPage.Window.Invoke("getMoreData", apiToCall, "People"); } } } }
public void SetData(PeopleData info) { m_data = info; m_HUDBoard.SetName(m_data.name); }
public void UpdatePeople() { inData = new PeopleData(); StartCoroutine(SendResponse()); }
public static void SetPeopleData(PeopleData pd_) { peopleData = pd_; }