public async static Task <UserItem> AddUser(IOutput output, IInput input, UserItem user) { if (!await UsernameExists(output, user.Username)) { var inUser = user.ToData(); inUser.MapDataId = await CityId(output, user.City); if (user.IsAdmin) { await input.Add(new AdminInfo() { user = inUser }); } else { await input.Add(inUser); } return(user); } else { throw new Exception("409", new Exception("username is taken")); } }
/// <summary> /// adds a map data resource to the database /// </summary> /// <param name="input">input</param> /// <returns>updated item after adding</returns> public async Task AddMapData(ViewMapData item) { var newItem = await input.Add(item.ToData()); item.ID = newItem.Id; }