Beispiel #1
0
        public async Task<IHttpActionResult> PutClan(int id, UpdateClanBindingModel updateClanModel)
        {
            if (!ModelState.IsValid)
                return BadRequest(ModelState);

            var clan = await TheClanStore.FindByIdAsync(id);

            if (clan == null)
                return NotFound();

            UpdateEntity(ref clan, updateClanModel);

            var result = await TheClanStore.UpdateAsync(clan);

            return !result.Succeeded
                ? GetErrorResult(result)
                : Ok();
        }
Beispiel #2
0
 protected void UpdateEntity(ref Clan clan, UpdateClanBindingModel updateClanModel)
 {
     if (updateClanModel.Name != null)
         clan.Name = updateClanModel.Name;
     if (updateClanModel.Description != null)
         clan.Description = updateClanModel.Description;
     if (updateClanModel.ClanCategory.HasValue)
         clan.ClanCategory = updateClanModel.ClanCategory.Value;
     if (updateClanModel.ClanKind.HasValue)
         clan.ClanKind = updateClanModel.ClanKind.Value;
 }