public TranslatedPerson Patch(string id, Person patch)
		{
			var person = _db.People.Include(c => c.Translations).SingleOrDefault(c => c.Id == id);

			person.Patch(patch);

			return new TranslatedPerson(person);
		}
Example #2
0
		public void Patch(Person patch)
		{
			foreach (var translationPatch in patch.Translations)
			{
				var translation = Translations.FirstOrDefault(t => t.Culture == translationPatch.Culture);
				if (translation == null) { continue; }

				if (translationPatch.Name != null) translation.Name = translationPatch.Name;
				if (translationPatch.Description != null) translation.Description = translationPatch.Description;
			}
		}
		public TranslatedPerson(Person person)
		{
			Id = person.Id;

			if (person.Translations != null && person.Translations.Any())
			{
				var translation = person.Translations.First();
				Culture = translation.Culture;
				Name = translation.Name;
				Description = translation.Description;
			}
		}
		public Person Post(Person person)
		{
			_db.People.Add(person);

			return person;
		}
		public TranslatedPerson Put(string id, Person updatePerson)
		{
			_db.Entry(updatePerson).State = EntityState.Modified;
			_db.Entry(updatePerson.Translations.First()).State = EntityState.Modified;
			return new TranslatedPerson(updatePerson);
		}
		public Person Post(Person person)
		{
			return _repository.Post(person);
		}
		public TranslatedPerson Put(string id, Person updatePerson)
		{
			return _repository.Put(id, updatePerson);
		}
		public TranslatedPerson Patch(string id, Person patch)
		{
			return _repository.Patch(id, patch);
		}