Exemple #1
0
        public async Task UpdateRelation(UpdateRelationModel updatedRelation)
        {
            var relationToUpdate = await GetRelation(updatedRelation.Id);

            relationToUpdate.Name            = updatedRelation.Name;
            relationToUpdate.FullName        = updatedRelation.FullName;
            relationToUpdate.EmailAddress    = updatedRelation.EmailAddress;
            relationToUpdate.TelephoneNumber = updatedRelation.TelephoneNumber;

            var relationAddress = relationToUpdate.RelationAddresses.Single();

            relationAddress.CountryId  = updatedRelation.CountryId;
            relationAddress.Street     = updatedRelation.Street;
            relationAddress.Number     = updatedRelation.Number;
            relationAddress.PostalCode = updatedRelation.PostalCode;
            relationAddress.City       = updatedRelation.City;

            var relationCategory = relationToUpdate.RelationCategories.Single();

            if (relationCategory.CategoryId != updatedRelation.RelationCategoryId)
            {
                _context.Remove(relationCategory);
                relationCategory = new RelationCategory
                {
                    CategoryId = updatedRelation.RelationCategoryId,
                    RelationId = updatedRelation.Id
                };
            }
            _context.Add(relationCategory);
            await _context.SaveChangesAsync();
        }
 public async Task UpdateRelation(UpdateRelationModel modelToUpdate)
 {
     await _relations.UpdateRelation(modelToUpdate);
 }
Exemple #3
0
        public async Task <IActionResult> EditRelation(UpdateRelationModel modelToUpdate)
        {
            await _service.UpdateRelation(modelToUpdate);

            return(Ok());
        }