public async Task <int> CreateAsync(string firstName, string nickname, string lastName, string bornCountry, int age, IFormFile picture) { var biography = new Biography { FirstName = firstName, Nickname = nickname, LastName = lastName, BornCountry = bornCountry, Age = age, }; if (picture != null) { var pictureUrl = await this.cloudinaryService.UploadAsync(picture, picture.FileName, CloudinaryFolderName); biography.PictureUrl = pictureUrl; } else { biography.PictureUrl = UnknownPictureUrl; } await this.biographiesRepository.AddAsync(biography); await this.biographiesRepository.SaveChangesAsync(); return(biography.Id); }
static void Main(string[] args) { //Books var book1 = new Biography("Napoleon", "Ponasenkov", true); var book2 = new Comix("Batman", "Marvel", false); var book3 = new Horror("It", "Steven King", true); var book4 = new Tutorial("C#", "Microsoft", false); var book5 = new Horror("Dagon", "Lovecraft", true); //Employees var vincent = new Warehouseman("Vicent", 39, 170, 60, 30000); var jules = new Consultant("Jules", 34, 179, 66, 29000); var butch = new Cashier("Butch", 28, 180, 58, 20000); //Clients var mr_green = new Client("MrGreen", 50, 190, 78, 30000); var mr_white = new Client("MrWhite", 50, 190, 78, 30000); var mr_brown = new Client("MrBrown", 50, 190, 78, 30000); var mr_pink = new Client("MrPink", 50, 190, 78, 30000); //Boss var boss = new Owner("Marsellus", 70, 169, 90); Console.WriteLine("==============="); WorkDay.Start(); }
public override int GetHashCode() { int hash = 1; if (ActorId != 0) { hash ^= ActorId.GetHashCode(); } if (Name.Length != 0) { hash ^= Name.GetHashCode(); } if (Surname.Length != 0) { hash ^= Surname.GetHashCode(); } if (Biography.Length != 0) { hash ^= Biography.GetHashCode(); } if (WikiUrl.Length != 0) { hash ^= WikiUrl.GetHashCode(); } if (ImageUrl.Length != 0) { hash ^= ImageUrl.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
private static Biography CopyBiography(string name, Biography biogr) { return(new Biography { Description = name + biogr.Description }); }
private void 添加新人物ToolStripMenuItem_Click(object sender, EventArgs e) { for (int i = 0x2328; i <= 0x270f; i++) { if (!this.Persons.HasGameObject(i)) { Person t = new Person(); t.Scenario = this.MainForm.Scenario; t.ID = i; t.SurName = "新"; t.GivenName = "人物"; t.PictureIndex = 0x7d1; t.Strain = t.ID; t.Alive = true; t.IdealTendency = this.MainForm.Scenario.GameCommonData.AllIdealTendencyKinds[0] as IdealTendencyKind; t.Character = this.MainForm.Scenario.GameCommonData.AllCharacterKinds[0]; this.Persons.Add(t); Biography biography = this.MainForm.Scenario.GameCommonData.AllBiographies.GetBiography(t.ID); if (biography == null) { biography = new Biography(); biography.ID = t.ID; biography.Scenario = t.Scenario; biography.FactionColor = 0; biography.MilitaryKinds.AddBasicMilitaryKinds(this.MainForm.Scenario); t.Scenario.GameCommonData.AllBiographies.AddBiography(biography); } t.PersonBiography = biography; this.RebindDataSource(); break; } } }
/// <summary> /// Save/Update Biography entity /// </summary> /// <param name="bio"><see cref="Biography"/> entity object.</param> /// <returns>Bool to confirm changes saved.</returns> public async Task <bool> SaveBiography(Biography bio) { _context.Entry(bio).State = EntityState.Modified; await _context.SaveChangesAsync(); try { await _context.SaveChangesAsync(); return(true); } catch (DbUpdateConcurrencyException ex) { if (!BiographyExists(bio.Id)) { _logger.LogError(ex, $"Failed saving updated Dog Biography entity, record doesn't exist (attempted Biography id: {bio.Id})."); } else { _logger.LogError(ex, $"Db Update Concurrency Exception while saving updated Dog Biography for Biography id {bio.Id}."); } return(false); } }
public void PreferredBiography_ItemsHasOneElement_ReturnsTheOneElement() { var biography = new Biography(); _subject.Items.Add(biography); _subject.PreferredBiography.Should().Be(biography); }
public DetailedHeroViewModel() { Powerstat = new Powerstats(); BiographyData = new Biography(); AppearanceValues = new Appearance(); WorkData = new Work(); Connection = new Connections(); }
protected void onClick_Biography(object sender, EventArgs e) { Biography.Focus(); Biography.Visible = true; Notifications.Visible = false; Created.Visible = false; Attended.Visible = false; Upcoming.Visible = false; }
public void UpdateBiography(Biography biography) { if (biography == null) { throw new ArgumentNullException(nameof(biography)); } _context.Biography.Update(biography); }
public ActionResult DeleteConfirmed(int id) { Biography biography = db.Biographies.Find(id); int i = biography.Persona.ID; db.Biographies.Remove(biography); db.SaveChanges(); return(Redirect("/Personas/Details/" + i)); }
public static void DBInit(SnilDBContext dBContext, string description, out Biography biography) { biography = new Biography { Description = description + _description }; dBContext.Biographies.Add(biography); dBContext.SaveChanges(); }
public ActionResult Edit([Bind(Include = "ID,Content")] Biography biography) { if (ModelState.IsValid) { db.Biographies.Find(biography.ID).Content = biography.Content; db.SaveChanges(); return(Redirect("/Personas/Details/" + db.Biographies.Find(biography.ID).Persona.ID)); } return(View(biography)); }
public Patient(Biography biography = null, Physical body = null, Mental mind = null) { Biography = biography ?? new Biography(); Body = body ?? new Physical(); Mind = mind ?? new Mental(); AccessPoints = new AccessPoints(); Flags = new PatientFlags(); //_randomSeed = MagicRandomStaticThingy; }
public override dynamic Create(GroupBox g) { Biography b = new Biography(base.Create(g)); GroupBox bioGroupBox = ((Grid)g.Content).Children.OfType <GroupBox>().First(x => x.Name == "HistBiographyGroup"); IEnumerable <TextBox> tbList = ((Grid)bioGroupBox.Content).Children.OfType <TextBox>(); b.Person = tbList.First(x => x.Name == "InpHistBioPerson").Text; b.Years = tbList.First(x => x.Name == "InpHistBioYears").Text; return(b); }
public ActionResult UpdateUser(Guid biographyId, Biography biography) { var biographyToUpdateFromRepo = _biographyRepository.GetBiography(biographyId); biographyToUpdateFromRepo.Id = biography.Id; biographyToUpdateFromRepo.Content = biography.Content; biographyToUpdateFromRepo.UserId = biography.UserId; _biographyRepository.Save(); return(Ok(biography)); }
static void Main(string[] args) { var paulBrown = new Biography("Paul", "Brown", "07,12,1995"); Console.WriteLine($"{paulBrown.Name}, {paulBrown.Surname}, {paulBrown.BirthDate}, {paulBrown.Age} "); var person = new Person(paulBrown); person.GetBiography(); person.SerializeOrDeserializeBio(paulBrown, Mode.Serialize); Console.ReadLine(); }
public Person[] run(int number) { Person[] persons = new Person[number]; Biography biography = new Biography(); Collection manBiography = readBiographyCollection(GENDER_MAN); Collection womanBiography = readBiographyCollection(GENDER_WOMAN); for (int i = 0; i < number; i++) { persons[i] = new Person(); persons[i].id = i; persons[i].nation = getRandomFromCollection(readNationsCollection()); persons[i].gender = getRandomFromArrays( new string[2] { GENDER_MAN, GENDER_WOMAN }, new int[2] { 90, 10 } ); persons[i].name = getRandomFromCollection( readNamesCollection(persons[i].gender, persons[i].nation) ); persons[i].surname = getRandomFromCollection( readSurnamesCollection(persons[i].nation) ); persons[i].age = getRandomBetween(20, 31); biography.applyBiography(persons[i], getRandomFromCollection(persons[i].gender == GENDER_MAN ? manBiography : womanBiography)); biography.applyBiography(persons[i], getRandomFromCollection(persons[i].gender == GENDER_MAN ? manBiography : womanBiography)); persons[i].nature = getRandomFromArrays( new string[3] { "Good", "Neutral", "Bad" }, new int[3] { 25, 50, 25 } ); checkAbilities(persons[i]); checkAge(persons[i]); persons[i].money = getRandomBetween(0, 31); } return(persons); }
/// <summary> /// Writes new Biography entity to database. /// </summary> /// <param name="bio"><see cref="Biography"/> entity object</param> /// <returns>New <see cref="Biography"/> entity with sql generated id.</returns> public async Task <Biography> CreateNewBiography(Biography bio) { _dbSet.Add(bio); await _context.SaveChangesAsync(); // include Dog and Owner relationship bio.Dog = await _context.Dogs .Where(d => d.Id == bio.DogId) .Include(d => d.Owner) .SingleOrDefaultAsync(); return(bio); }
public void PreferredBiography_ItemsHasMoreThenOneBiographyAndNoneIsFromLastFMButOrWikipedia_ReturnsTheBiographyWithTheLongestText() { var biography1 = new Biography { Site = "test", Text = "test123" }; var biography2 = new Biography { Site = "test2", Text = "test1234" }; _subject.Items.AddRange(new[] { biography1, biography2 }); _subject.PreferredBiography.Should().Be(biography2); }
public void PreferredBiography_ItemsHasMoreThenOneBiographyAndNoneIsFromLastFMButOneIsFromWikipedia_ReturnsTheBiographyFromWikipedia() { var biography1 = new Biography { Site = "test" }; var biography2 = new Biography { Site = "wikipedia" }; _subject.Items.AddRange(new[] { biography1, biography2 }); _subject.PreferredBiography.Should().Be(biography2); }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Biography biography = db.Biographies.Find(id); if (biography == null) { return(HttpNotFound()); } return(View(biography)); }
public ActionResult EditBio(Biography model) { bool result = false; if (model.Id > 0) { result = BrRepo.Update(model); } else { result = BrRepo.Add(model); } return(Json(result, JsonRequestBehavior.AllowGet)); }
public void AddBiography(Guid userId, Biography biography) { if (userId == Guid.Empty) { throw new ArgumentNullException(nameof(userId)); } if (biography == null) { throw new ArgumentNullException(nameof(biography)); } // always set the AuthorId to the passed-in authorId biography.UserId = userId; _context.Biography.Add(biography); }
public ActionResult GetBIO() { var usermanager = IdentityTools.NewUserManager(); var uid = usermanager.FindByName(User.Identity.Name); Biography bio = new Biography(); bio = BrRepo.Get(x => x.UserId == uid.Id); string value = string.Empty; value = JsonConvert.SerializeObject(bio, Formatting.Indented, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }); return(Json(value, JsonRequestBehavior.AllowGet)); }
/// <summary> /// Creates new single <see cref="Biography"/> /// </summary> /// <param name="dogId">Dog Id <see cref="int"/></param> /// <param name="userId">User Id <see cref="string"/></param> /// <returns>Created (mapped) <see cref="DogBiography"/> instance with SQL generated Id</returns> public async Task <DogBiography> CreateBiography(int dogId, string userId) { DateTime now = DateTime.Now; Biography bio = new Biography { DogId = dogId, Created = now, LastModified = now, CreatedBy = userId, LastModifiedBy = userId }; return(_mapper.Map <DogBiography>( await _repository.CreateNewBiography(bio) )); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } Biography = await _context.Biographies .Include(b => b.Author).FirstOrDefaultAsync(m => m.Id == id); if (Biography == null) { return(NotFound()); } return(Page()); }
/// <summary> /// Find single Biography entity by dogId. /// </summary> /// <param name="dogId">Dog Id <see cref="int"/></param> /// <returns><see cref="Biography"/> entity</returns> public async Task <Biography> FindBiography(int dogId) { Biography bio = await _dbSet .Where(b => b.DogId == dogId) .SingleOrDefaultAsync(); if (bio != null) { bio.Dog = await _context.Dogs .Where(d => d.Id == dogId) .Include(d => d.Owner) .SingleOrDefaultAsync(); } return(bio); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } Biography = await _context.Biographies .Include(b => b.Author).FirstOrDefaultAsync(m => m.Id == id); if (Biography == null) { return(NotFound()); } ViewData["AuthorId"] = new SelectList(_context.Authors, "Id", "Id"); return(Page()); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Biography = await _context.Biographies.FindAsync(id); if (Biography != null) { _context.Biographies.Remove(Biography); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
private List<Biography> ParseBiographyXml(XPathNodeIterator iterator) { List<Biography> res = new List<Biography>(); while (iterator.MoveNext()) { Biography a = new Biography(); XPathNodeIterator biographyIterator = iterator.Current.SelectChildren(XPathNodeType.Element); while (biographyIterator.MoveNext()) { if (biographyIterator.Current.Value == string.Empty) continue; if (biographyIterator.Current.Name == "url") a.Url = biographyIterator.Current.Value; if (biographyIterator.Current.Name == "site") a.Site = biographyIterator.Current.Value; //ADD HANDLING OF LICENCE TYPE // //if (biographyIterator.Current.Name == "licence") // a.Licence = biographyIterator.Current.Value; if (biographyIterator.Current.Name == "text") a.Text = biographyIterator.Current.Value; } res.Add(a); } return res; }